IncludedMembers Property

Microsoft Office Web Components Object Model

IncludedMembers Property

       

Returns or sets the members to be displayed in the specified field. This property can be set to a single member or a Variant array of members. The members can be passed as one or more PivotMember objects, member names, or unique member names. Read/write.

expression.IncludedMembers

expression   Required. An expression that returns a PivotField object.

Remarks

Members not listed when you set this property may still appear in the PivotTable list if their parent member is included. Setting this property clears all previous settings of this property for the specified field. You can set this property to Empty (IncludedMembers = Empty) or to a zero-length Variant array (IncludedMembers = Array()) to clear the included members list for the specified field.

Example

This example sets the included and excluded members of the Store State and Store City fields in PivotTable1.

Sub Member_Filtering()

    Dim fldStoreCity
    Dim fldStoreState
    Dim ptView

    ' Set a variable to the current PivotTable view.
    Set ptView = PivotTable1.ActiveView

    ' Set a variable to the Store State field.
    Set fldStoreState = ptView.FieldSets("Store").Fields("Store State")

    ' Set a variable to the Store City field.
    Set fldStoreCity = ptView.FieldSets("Store").Fields("Store City")

    ' Exclude California and Washington from the Store State field.
    fldStoreState.ExcludedMembers = Array("CA", "WA")

    ' Include members of the Store City field. Note that the cities are
    ' in states that have been excluded by the previous line. Since
    ' Store State is a parent to Store City, then the excluded states
    ' are displayed in the PivotTable.
    fldStoreCity.IncludedMembers = Array("Los Angeles", "San Diego", _
                                         "Seattle", "Spokane")

End Sub