简体   繁体   中英

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?

尝试在行之前清除过滤器:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM