PivotItems Method

Applies To

PivotField Object.

Description

Accessor. Returns an object that represents a single pivot item (a PivotItem object, Syntax 1) or a collection of all the visible and hidden pivot items (a PivotItems object, Syntax 2) in the specified field. Read-only.

Syntax 1

object.PivotItems(index)

Syntax 2

object.PivotItems

object

Required. The PivotField object.

index

Required for Syntax 1. The number or name of the pivot item to return (can be an array to specify more than one).

See Also

ChildItems Method, HiddenItems Method, ParentItems Method, VisibleItems Method.

Example

This example adds the names of all items in the field named "COMPANY" to a list box. The list box appears on Sheet1.


Set pvtTable = Worksheets("Sheet1").Range("A3").PivotTable
Set newListBox = Worksheets("Sheet1").ListBoxes.Add _
    (Left:=10, Top:=72, Width:=144, Height:=144)
Set pvtField = pvtTable.PivotFields("COMPANY")
For Each pvtItem In pvtField.PivotItems
    newListBox.AddItem (pvtItem.Name)
Next pvtItem
Worksheets("Sheet1").Activate