vba 对 2 个以上的条件使用自动过滤器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21834701/
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
Use autofilter on more than 2 criteria
提问by methuselah
How do you use VBA autofilter on more than 2 variables - I keep getting the error message:
您如何对 2 个以上的变量使用 VBA 自动过滤器 - 我不断收到错误消息:
Named argument not found
未找到命名参数
Code below:
代码如下:
.AutoFilter Field:=1, Criteria1:="HP Compaq 6000", Operator:=xlOr, Criteria2:="HP Compaq 8000", Operator:=xlOr, Criteria3:="HP Compaq 8200", Operator:=xlOr, Criteria4:="HP Compaq 8200 Elite", Operator:=xlOr, Criteria5:="HP Compaq dc5800", Operator:=xlOr, Criteria6:="HP Compaq dc7900", Operator:=xlOr, Criteria7:="HP Compaq Elite 8300 SFF", Operator:=xlOr, Criteria8:="HP Compaq Pro 8300 SFF"
I would like to know if it is possible to filter data with more than 2 criteria in the same column using the AutoFilter. If there isn't, is there another way to accomplish this objective?
我想知道是否可以使用自动筛选器在同一列中筛选具有 2 个以上条件的数据。如果没有,是否有另一种方法来实现这一目标?
回答by Dmitry Pavliv
Use this one instead:
改用这个:
.AutoFilter Field:=1, Criteria1:=Array("HP Compaq 6000", "HP Compaq 8000", _
"HP Compaq 8200", "HP Compaq 8200 Elite", _
"HP Compaq dc5800", "HP Compaq dc7900", _
"HP Compaq Elite 8300 SFF", "HP Compaq Pro 8300 SFF"), _
Operator:=xlFilterValues