Modifying formula of calculated field depending ypon the selection of pagefield

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top