Version Information
Version Added: Excel

Syntax

expression.Add(Type, DataField, value1, Value2, Order, Name, Description, IsMemberPropertyFilter, MemberPropertyField)

expression A variable that represents a PivotFilters object.

Parameters

Name Required/Optional Data Type Description
Type Required XlPivotFilterType Requires an type of filter.
DataField Optional Variant The field to which the filter is attached.
Value1 Optional Variant Filter value 1.
Value2 Optional Variant Filter value 2.
Order Optional Variant Order in which the data should be filtered.
Name Optional Variant Name of the filter.
Description Optional Variant A brief description of the filter.
MemberPropertyField Optional Variant Specifies the member property field on which the label filter is based.

Return Value
PivotFilter

Example

Following are some examples of how to use the Add function correctly.

Visual Basic for Applications
ActiveCell.PivotField.PivotFilters.Add FilterType := xlThisWeek ActiveCell.PivotField.PivotFilters.Add FilterType := xlTopCount DataField := MyPivotField2 Value1 := 10 ActiveCell.PivotField.PivotFilters.Add FilterType := xlCaptionIsNotBetween Value1 := "A" Value2 := "G" ActiveCell.PivotField.PivotFilters.Add FilterType := xlValueIsGreaterThanOrEqualTo DataField := MyPivotField2 Value1 := 10000 

The following example returns a run-time error because the data type of Value1 is invalid.

Visual Basic for Applications
ActiveCell.PivotField.PivotFilters.Add FilterType := xlValueIsGreaterThanOrEqualTo DataField := MyPivotField2 Value1 := "Allan"

See also: