Skip to main content

PivotItems object

Table of contents
  1. Remarks
  2. Example

A collection of all the PivotItem objects in a PivotTable field.


The items are the individual data entries in a field category.


Use the PivotItems method of the PivotField object to return the PivotItems collection.

The following example creates an enumerated list of field names and the items contained in those fields for the first PivotTable report on Sheet4.

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
        C = C + 1
End With

Use PivotItems (index), where index is the item index number or name, to return a single PivotItem object. The following example hides all entries in the first PivotTable report on Sheet3 that contain "1998" in the Year field.

Worksheets("sheet3").PivotTables(1).PivotFields("year").PivotItems("1998").Visible = False

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>