Help on Unable to get the CurrentPage property of the PivotField class' using VBA

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
 

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