Excel 2013 VBA清除所有过滤器宏 [英] Excel 2013 VBA Clear All Filters macro

查看:1113
本文介绍了Excel 2013 VBA清除所有过滤器宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎较旧的宏不起作用。我有适当的安全设置来运行VBA宏,但是当我尝试了一些清除工作表上所有过滤器的方法时,我收到一个编译错误。



这是我的已尝试:



  
Sub AutoFilter_Remove()
'此宏按顺序删除任何过滤显示所有数据,但不会删除过滤器箭头
ActiveSheet.ShowAllData
End Sub



我在表格上有按钮以清除所有过滤器,以方便用户使用,因为工作表中有很多具有过滤器的列。

解决方案

如果表格中已经有过滤器,则:

  Sub Macro1()
Cells.AutoFilter
End Sub

将其删除。


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 compile error.

Here is what I have tried:


Sub AutoFilter_Remove()
'This macro removes any filtering in order to display all of the data but it does not remove the filter arrows
ActiveSheet.ShowAllData
End Sub

I have buttons on the sheets to clear all filters for ease of use for users since the sheets has a lot of columns that have filters on them.

解决方案

If the sheet already has a filter on it then:

Sub Macro1()
    Cells.AutoFilter
End Sub

will remove it.

这篇关于Excel 2013 VBA清除所有过滤器宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆