Name

pivotfield.CurrentPageName [= setting]

Synopsis

For OLAP page fields with EnableMultiplePageItems set to False, sets or returns the name of the selected item in the page field. For example, the following code selects a single store in the FoodMart Sales pivot table:

Sub ViewSingleStore2(  )
    Dim pt As PivotTable, pf As PivotField
    ' Uncomment this line to create pivot table.
    'CreateOLAPPivotTable
    ' Get pivot table.
    Set pt = Worksheets("Foodmart Sales").PivotTables(1)
    ' Get pivot field.
    Set pf = pt.PivotFields("[Store]")
    ' Disable multiselect.
    pf.CubeField.EnableMultiplePageItems = False
    ' Select single store.
    pf.CurrentPageName = "[Store].[All Stores].[USA].[CA].[Alameda]"
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.