ExcludedMembers Property

Microsoft Office Web Components Visual Basic

expression.ExcludedMembers

expression    Required. An expression that returns a PivotField object.

Remarks

Members that are explicitly excluded still appear in the PivotTable list if one or more of their children are included. Setting this property clears all previous settings of this property for the specified field. You can set the ExcludedMembers property to Empty (ExcludedMembers = Empty) or to a zero-length Variant array (ExcludedMembers = 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