vba Excel 宏 - 如何获取自动筛选行的范围?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/784973/
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
Excel Macros - How do I get Range of AutoFiltered rows?
提问by Vid L
OK, so I have set AutoFilter property for the whole of the active worksheet (UsedRange.AutoFilter Field:=1, Criteria1:= [blah blah]
)
好的,我已经为整个活动工作表 ( UsedRange.AutoFilter Field:=1, Criteria1:= [blah blah]
)设置了 AutoFilter 属性
Once the filter is applied, how do I programmatically select the range if rows and columns that are the result of the filter.
应用过滤器后,如果行和列是过滤器的结果,我如何以编程方式选择范围。
I checked UsedRange, but that gives the whole (unfiltered) range. Any ideas?
我检查了 UsedRange,但这给出了整个(未过滤的)范围。有任何想法吗?
回答by Vid L
Got it.
知道了。
Set rng = Worksheets("Sheet1").Range("A1").CurrentRegion.SpecialCells(xlVisible)