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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 10:23:50  来源:igfitidea点击:

Excel Macros - How do I get Range of AutoFiltered rows?

excel-vbafiltervbaexcel

提问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)