Excel 2013 VBA Clear All Filters macro

后端 未结 26 926
花落未央
花落未央 2020-11-27 16:26

It seems older macros are not working. I have proper securtiy set to run VBA macros but when I have tried a few methods for clearing ALL filters on a worksheet, I get a comp

26条回答
  •  [愿得一人]
    2020-11-27 17:18

    Loop AutoFilter columns, if column is activated(on) then reset a column filter, you may insert a new criteria after a loop. This code does not remove AutoFilter banner.

    Dim iCol as Long
    Dim ws as Worksheet
    ...
    For iCol = 1 To ws.AutoFilter.Filters.count
      If ws.AutoFilter.Filters(iCol).On Then ws.AutoFilter.Range.AutoFilter Field:=iCol
    Next
    ...
    ws.AutoFilter.Range.AutoFilter Field:=4, Criteria1:="AABBCC"
    

提交回复
热议问题