Sub testFilteringCol5()
Dim arrCrit() As Variant, i As Long
arrCrit = Range("Q1:V1").value 'place the range in an array
'cast each array element to string:
For i = 1 To UBound(arrCrit, 2): arrCrit(1, i) = CStr(arrCrit(1, i)): Next i
'use the strings array as `Criteria1` (columns headers must exist on the 6th row):
ActiveSheet.Range("A6").AutoFilter field:=6, Criteria1:=arrCrit, Operator:=xlFilterValues
End Sub
1条答案
按热度按时间2sbarzqh1#
好吧,你可以(直接)提取一个数组用作Criteria。但是数组元素必须是字符串,即使过滤后的列包含数字.
请尝试下一种方式:
字符串
请在测试后发送一些反馈。