ranopano
ranopano

Reputation: 539

Filtering Pivot Table Using VBA

I am trying to write out some VBA code to filter a pivottable of mine to show only records greater than 0.

When I run the code, I receive ther error "Application-defined or object-defined error".

I really have no idea what is causing the issue, so hoping for some assistance from you all!

Here's my code:

 Sheet32.PivotTables("PivotTable11").PivotFields("Retail Division"). _
        PivotFilters.Add Type:=xlValueIsGreaterThan, DataField:=Sheet32.PivotTables("PivotTable11").PivotFields("Sum of Recordable Injuries"), Value1:=0

Any ideas why the code is not running?

Upvotes: 0

Views: 125

Answers (1)

J.Doe
J.Doe

Reputation: 596

Try clearing the filter before your line :

 Sheet32.PivotTables("PivotTable11").PivotFields("Retail Division").ClearAllFilters

Upvotes: 2

Related Questions