Home > Back-end >  How to list pivot filter item using VBA?
How to list pivot filter item using VBA?

Time:05-22

I want to get items in pivot analysis filter using VBA , Is there any function support?

enter image description here

CodePudding user response:

Try the following code.

Sub test()

Dim pt As PivotTable
Dim pf As PivotField


Set pt = Sheets("Sheets").PivotTables("PivotTables")
Set pf = pt.PivotFields("PivotFields")

With pf
    For i = 1 To .PivotItems.Count
        Debug.Print .PivotItems(i).Name
    Next i
End With

End Sub
  • Related