FilterOn Property
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
Returns a PivotTotal object that represents the total to use when conditionally filtering a field.
expression.FilterOn
expression Required. An expression that returns a PivotField object.
Example
This example applies a conditional filter to the Store City field based on the Profit total. The three most profitable stores are displayed.
Sub TopThreeStores()
Dim ptView
Dim ptConstants
Dim fldFilterField
Set ptConstants = PivotTable1.Constants
' Set a variable to the active view of the PivotTable list.
Set ptView = PivotTable1.ActiveView
' Set a variable to the field that is to be filtered.
Set fldFilterField = PivotTable1.ActiveData.RowAxis.Fields("Store City")
' Filter the stores based on profit.
Set fldFilterField.FilterOn = ptView.Totals("Profit")
' Set the function used to filter the stores.
fldFilterField.FilterFunction = ptConstants.plFilterFunctionTopCount
' Display the three most profitable stores.
fldFilterField.FilterFunctionValue = 3
End Sub