Skip to content

Latest commit

 

History

History
70 lines (43 loc) · 2.16 KB

Excel.PivotFilters.Add.md

File metadata and controls

70 lines (43 loc) · 2.16 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
PivotFilters.Add method (Excel)
vbaxl10.chm772078
vbaxl10.chm772078
Excel.PivotFilters.Add
bf3bb727-4c00-1f8e-5acd-af0b974cba5b
05/07/2019
medium

PivotFilters.Add method (Excel)

Adds new filters to the PivotFilters collection.

Syntax

expression.Add (Type, DataField, Value1, Value2, Order, Name, Description, MemberPropertyField, WholeDayFilter)

expression A variable that represents a PivotFilters object.

Parameters

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.

Return value

PivotFilter

Example

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]