Name
pivotfield
.PivotItems([Index])
Synopsis
Returns the collection of PivotItems
for the field. The following code displays the pivot fields and items from a pivot table in the Immediate window:
Sub ShowPivotTableValues( ) Dim pt As PivotTable, pf As PivotField, pi As PivotItem ' Exit if pivot table doesn't exist. If ActiveSheet.PivotTables.Count < 1 Then Exit Sub ' Get pivot table. Set pt = ActiveSheet.PivotTables(1) ' Get pivot fields For Each pf In pt.PivotFields ' Display pivot fields and items in outline form. Debug.Print pf.name For Each pi In pf.PivotItems Debug.Print , pi.Value Next Next End Sub
Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.