Deselect all items in a pivot table using vba

前端 未结 5 751
野的像风
野的像风 2021-01-12 13:43

Can some quicly explain the way to deselect all items in a newly created pivot table so that I can go back and select only one or two items? I tried the following:



        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-12 14:09

    I've found that looping through each data item takes a lot of time, what you can do if you want to filter on a single item in a pivot without looping through all items is use the following code:

    ActiveSheet.PivotTables("Your Pivot Name").PivotFields("Your Field Name").ClearAllFilters
    ActiveSheet.PivotTables("Your Pivot Name").PivotFields("Your Field Name").PivotFilters.Add _
        Type:=xlCaptionEquals, Value1:="Your string here" 
    

    this is basically a label filter but it worked for me.

提交回复
热议问题