Class PivotFields (Excel VBA)

A collection of all the PivotField objects in a PivotTable report. To use a PivotFields class variable it first needs to be instantiated, for example


Dim pfs as PivotFields
Set pfs = ActiveCell.PivotTable.VisibleFields

Count

Returns a Long value that represents the number of objects in the collection.


Dim lngCount As Long
lngCount = ActiveCell.PivotTable.VisibleFields.Count

Item

Returns a single object from a collection.

The text name of the object is the value of the Name and Value properties.

Item (Index)

Index: The name or index number for the object.


Dim pvtf As PivotField
Set pvtf = ActiveCell.PivotTable.VisibleFields(Index:=1)