我有一个包含多列的表,我想使用条件过滤表并接收带有匹配项的范围。(1) 我知道我可以使用循环轻松地在表中进行迭代,或者 (2) 我可以在列中添加过滤器。
我不喜欢(1),因为表中的迭代太慢了,但我可以做到这一点。
Excel 是否有一个函数可以一步返回一个按特定条件过滤的范围?类似'function multipleVlookup(...) As Range'
编辑: 回答后我的代码:(感谢亚历山大)
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