title | keywords | f1_keywords | api_name | ms.assetid | ms.date | ms.localizationpriority | ||
---|---|---|---|---|---|---|---|---|
PivotFilters.Add method (Excel) |
vbaxl10.chm772078 |
|
|
bf3bb727-4c00-1f8e-5acd-af0b974cba5b |
05/07/2019 |
medium |
Adds new filters to the PivotFilters collection.
expression.Add (Type, DataField, Value1, Value2, Order, Name, Description, MemberPropertyField, WholeDayFilter)
expression A variable that represents a PivotFilters object.
Name | Required/Optional | Data type | Description |
---|---|---|---|
Type | Required | XlPivotFilterType | Requires an XlPivotFilterType 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. |
WholeDayFilter | Optional | Variant | Specifies a filter based on days. |
PivotFilter
Following are some examples of how to use the Add function correctly.
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.
ActiveCell.PivotField.PivotFilters.Add FilterType := xlValueIsGreaterThanOrEqualTo DataField := MyPivotField2 Value1 := Allan
[!includeSupport and feedback]