PivotItems Collection Object
Description
A collection of all the PivotItem objects in a pivot field. The items are the individual data entries in a field category.
Using the PivotItems Collection
Use the PivotItems method to return the PivotItems collection. The following example creates an enumerated list of pivot field names and the items contained in those fields for PivotTable one on Sheet4.
Worksheets("Sheet4").Activate
With Worksheets("Sheet3").PivotTables(1)
c = 1
For i = 1 To .PivotFields.Count
r = 1
Cells(r, c) = .PivotFields(i).Name
r = r + 1
For x = 1 To .PivotFields(i).PivotItems.Count
Cells(r, c) = .PivotFields(i).PivotItems(x).Name
r = r + 1
Next
c = c + 1
Next
End With
Use PivotItems(index), where index is the pivot item index number or name to return a single PivotItem object. The following example hides all entries in PivotTable one on Sheet3 that contain "1998" in the Year field.
Worksheets("Sheet3").PivotTables(1) _
.PivotFields("Year").PivotItems("1998").Visible = False
Properties
Application property, Count property, Creator property, Parent property.
Methods
Add method (PivotItems collection), Item method (PivotItems collection).