T
Tewari
I want to read the selection made in the Page Field of a pivot using
VBA. I am using something like following but getting error 'Number
1004 Unable to get the CurrentPage property of the PivotField class'
Can you please help me in correcting this.
Private Sub Worksheet_Calculate()
Dim pvtTable As PivotTable
Dim pvtField As PivotField
Dim pvtItem As PivotItem
Dim DefaultExists As Boolean
Dim DefaultNum As Variant
Dim FirstIncludedNum As Variant
Set pvtTable = ActiveSheet.PivotTables(1)
For i = 1 To pvtTable.PageFields.Count
Set pvtField = pvtTable.PageFields(i)
If pvtField.CurrentPage = "(All)" Then
' Do Something
End if
Next
VBA. I am using something like following but getting error 'Number
1004 Unable to get the CurrentPage property of the PivotField class'
Can you please help me in correcting this.
Private Sub Worksheet_Calculate()
Dim pvtTable As PivotTable
Dim pvtField As PivotField
Dim pvtItem As PivotItem
Dim DefaultExists As Boolean
Dim DefaultNum As Variant
Dim FirstIncludedNum As Variant
Set pvtTable = ActiveSheet.PivotTables(1)
For i = 1 To pvtTable.PageFields.Count
Set pvtField = pvtTable.PageFields(i)
If pvtField.CurrentPage = "(All)" Then
' Do Something
End if
Next