Class PivotFilters (Excel VBA)

The PivotFilters object is a collection of PivotFilter objects. To use a PivotFilters class variable it first needs to be instantiated, for example


Dim pfs as PivotFilters
Set pfs = ActiveCell.PivotTable.ActiveFilters

For Each

Here is an example of processing the PivotFilters items in a collection.


Dim pvtfil As PivotFilter
For Each pvtfil In ActiveCell.PivotTable.PivotFilters
	
Next pvtfil

Add2

Add2 (Type, DataField, Value1, Value2, Order, Name, Description, MemberPropertyField, WholeDayFilter)


Dim pvtfilAdd2 As PivotFilter
Set pvtfilAdd2 = ActiveCell.PivotTable.ActiveFilters.Add2(Type:=xlAfter)

Arguments

The following argument is required

Type - XlPivotFilterType

Here you can find possible values for XlPivotFilterType

Optional arguments

The following arguments are optional

DataField

Value1

Value2

Order

Name - String

Description - String

MemberPropertyField

WholeDayFilter

Count

Returns the number of items in the PivotFilters collection.


Dim lngCount As Long
lngCount = ActiveCell.PivotTable.ActiveFilters.Count

Item

Returns a specific element of the PivotFilters collection object by its position in the collection.

Item (Index)

Index: Specifies the position of an element of the collection.


Dim pvtfilItem As PivotFilter
Set pvtfilItem = ActiveCell.PivotTable.ActiveFilters(Index:=1)