T
Tewari
In a pivot table depending upon the selection of a pagefield value I
have to populate the value of a calculated field in row.
Suppose Page field can have selections Income1 , Income2 and All then
my calculated field will use different formula for three selections.
I have tried some thing like this but its not working.
I will really appreciate a quick response.
Private Sub Worksheet_Calculate()
'Call CalculateIncomeSegment
Debug.Print
ActiveSheet.PivotTables("PivotTable1").PivotFields("Income
").CurrentPage
End Sub
Private Sub CalculateIncomeSegment()
If ActiveSheet.PivotTables("PivotTable1").PivotFields("Income
").CurrentPage = "(All)" Then
ActiveSheet.PivotTables("PivotTable1").CalculatedFields( _
"Percent in Particular Segment").StandardFormula = "=inc_segA/
apps"
ElseIf ActiveSheet.PivotTables("PivotTable1").PivotFields("Income
").CurrentPage = "INCOME1" Then
ActiveSheet.PivotTables("PivotTable1").CalculatedFields( _
"Percent in Particular Segment").StandardFormula = "=inc_seg1/
apps"
ElseIf ActiveSheet.PivotTables("PivotTable1").PivotFields("Income
").CurrentPage = "INCOME2" Then
ActiveSheet.PivotTables("PivotTable1").CalculatedFields( _
"Percent in Particular Segment").StandardFormula = "=inc_seg2/
apps"
End If
End Sub
have to populate the value of a calculated field in row.
Suppose Page field can have selections Income1 , Income2 and All then
my calculated field will use different formula for three selections.
I have tried some thing like this but its not working.
I will really appreciate a quick response.
Private Sub Worksheet_Calculate()
'Call CalculateIncomeSegment
Debug.Print
ActiveSheet.PivotTables("PivotTable1").PivotFields("Income
").CurrentPage
End Sub
Private Sub CalculateIncomeSegment()
If ActiveSheet.PivotTables("PivotTable1").PivotFields("Income
").CurrentPage = "(All)" Then
ActiveSheet.PivotTables("PivotTable1").CalculatedFields( _
"Percent in Particular Segment").StandardFormula = "=inc_segA/
apps"
ElseIf ActiveSheet.PivotTables("PivotTable1").PivotFields("Income
").CurrentPage = "INCOME1" Then
ActiveSheet.PivotTables("PivotTable1").CalculatedFields( _
"Percent in Particular Segment").StandardFormula = "=inc_seg1/
apps"
ElseIf ActiveSheet.PivotTables("PivotTable1").PivotFields("Income
").CurrentPage = "INCOME2" Then
ActiveSheet.PivotTables("PivotTable1").CalculatedFields( _
"Percent in Particular Segment").StandardFormula = "=inc_seg2/
apps"
End If
End Sub