Skip to content

Latest commit

 

History

History
72 lines (50 loc) · 1.77 KB

Excel.PivotItems.md

File metadata and controls

72 lines (50 loc) · 1.77 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
PivotItems object (Excel)
vbaxl10.chm247072
vbaxl10.chm247072
Excel.PivotItems
df47021a-2b06-fa10-5712-58956c7ffe07
03/30/2019
medium

PivotItems object (Excel)

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

Remarks

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

Example

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.

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 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

Methods

Properties

See also

[!includeSupport and feedback]