VBA Excel autofiltermode = false 不关闭自动过滤器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24864408/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VBA Excel autofiltermode = false not turning off autofilter
提问by ghostracer34
Have used activesheet.autofiltermode = false
and
用过activesheet.autofiltermode = false
和
dim Myworksheet as worksheet
Myworksheet.autofiltermode = false
Neither removed autofilter I've use Myworksheet.ShowAllData
beforehand as well.
Using Office 2013 Professional Plus
也没有删除我Myworksheet.ShowAllData
事先使用过的自动过滤器。使用 Office 2013 专业增强版
回答by Rory
For a table you need different syntax:
对于表,您需要不同的语法:
activesheet.listobjects(1).Autofilter.showalldata
to clear the filter, or:
清除过滤器,或:
activesheet.listobjects(1).ShowAutoFilter = False
if you don't want the dropdowns visible at all.
如果您根本不希望下拉菜单可见。
回答by M Dattoli
This finallyhelped me figure out how to ensure that an Excel table's AutoFilter is on and showing all data. My final code is this:
这最终帮助我弄清楚如何确保 Excel 表的自动筛选器已打开并显示所有数据。我的最终代码是这样的:
If ActiveSheet.ListObjects(1).ShowAutoFilter Then
ActiveSheet.ListObjects(1).AutoFilter.ShowAllData
Else
ActiveSheet.ListObjects(1).ShowAutoFilter = True
End If