Excel宏 - 如何获取自动筛选行的范围?

时间:2023-02-08 07:11:54

OK, so I have set AutoFilter property for the whole of the active worksheet (UsedRange.AutoFilter Field:=1, Criteria1:= [blah blah])

好的,所以我为整个活动工作表设置了AutoFilter属性(UsedRange.AutoFilter Field:= 1,Criteria1:= [blah blah])

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,但是它给出了整个(未过滤的)范围。有任何想法吗?

1 个解决方案

#1


Got it.

Set rng = Worksheets("Sheet1").Range("A1").CurrentRegion.SpecialCells(xlVisible)

#1


Got it.

Set rng = Worksheets("Sheet1").Range("A1").CurrentRegion.SpecialCells(xlVisible)