Name

pivottable.PivotSelect(Name, [Mode], [UseStandardName])

Synopsis

Selects part of a pivot table.

Argument

Settings

Name

The name of the field or item to select.

Mode

An xlPTSelectionMode constant indicating the item within Name to select. Can be xlBlanks, xlButton, xlDataAndLabel (default), xlDataOnly, xlFirstRow, xlLabelOnly, or xlOrigin.

UseStandardName

True uses U.S. English formats for numbers, currency, dates, and times within the Name argument; False uses localized formats.

The following code selects the rows for Essential SharePoint from the pivot table created earlier (see Figure 13-7 for an illustration of the pivot table):

Sub SelectPivotItem(  )
    Dim pt As PivotTable
    ' Run CreatePivotTable to create this pivot table.
    Set pt = ActiveSheet.PivotTables(1)
    ' Select one item.
    pt.PivotSelect "ProductName[Essential SharePoint]"
    ' This line is equivalent to preceding line:
    'pt.PivotSelection = "ProductName[Essential SharePoint]"
End Sub

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.