查找使用多种标准的所有结果(Find all result using multiple crite

2019-09-21 13:31发布

我有多个列一个表,我想用指标分析过滤表,并接受范围与匹配。 (1)I知道我可以在使用列中的一个环或(2)I可以添加过滤器表中轻松地重复。

我不喜欢(1),因为迭代表太慢,但我可以做到这一点。

Excel中是否有返回与一步一定条件筛选范围内的功能? 喜欢的东西“功能multipleVlookup(...)由于范围”

编辑:答案后,我的代码:(感谢亚历山大)

Set tableRange = Range("A1:M" & lastRow)

' Filter 
With tableRange
    Call .AutoFilter(5, "test1")
    Call .AutoFilter(11, "test2")
    Call .AutoFilter(9, myDate)
End With

Set filteredRange = tableRange.SpecialCells(xlCellTypeVisible)

' Disable Filter
With tableRange
    Call .AutoFilter(5)
    Call .AutoFilter(11)
    Call .AutoFilter(9)
End With

' Do something with this result
For Each c In f.Cells.Rows
    actualRow = c.Row
    If actualRow <> 1 Then
        ' Do something
    End If
Next

Answer 1:

如果您可以过滤数据,就可以使用该表的Range ,并调用SpecialCells方法是这样的:

Dim table_range as Range
Dim filtered_range as Range

Set table_range = Range(...)
table_range.AutoFilter field:=... criteria1:=...
Set filtered_range = table_range.SpecialCells(xlCellTypeVisible)

这将返回一个Range只包含原始范围的可见单元格的对象。



文章来源: Find all result using multiple criteria