VBA-“不包含”-过滤器(excel 2010)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13046645/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 18:11:57  来源:igfitidea点击:

VBA - "does not contain"-filter (excel 2010)

vb.netexcelvbafilter

提问by Bulki

Possible Duplicate:
Combine multiple exclusion (<>) criteria in AutoFilter

可能重复:
在自动筛选中组合多个排除 (<>) 条件

I'm trying to set up a filter with multiple 'Does not containt' values. I seem to get an error doh every time I try to run it. I've looked up this error and it means that excel didn't find any value's. When I try to run the same code, only with one value, it works fine. Any help/suggestions?

我正在尝试设置具有多个“不包含”值的过滤器。每次我尝试运行它时,我似乎都会收到一个错误。我查了这个错误,这意味着 excel 没有找到任何值。当我尝试运行相同的代码时,只有一个值,它工作正常。任何帮助/建议?

Code with multiple values:

具有多个值的代码:

ActiveSheet.Range("$A:$J8").AutoFilter Field:=5, Criteria1:=Array("<>*a*", "<>*b*", "<>*c*"), Operator:=xlFilterValues

Code with only one value:

只有一个值的代码:

ActiveSheet.Range("$A:$J8").AutoFilter Field:=5, Criteria1:="<>*a*", Operator:=xlFilterValues

Greetz Bulki

格雷茨·布尔基

回答by pete

Have you tried this?

你试过这个吗?

ActiveSheet.Range("$A:$J8").AutoFilter Field:=5, Criteria1:="<>*a*", Operator:=xlAnd, Criteria2:="<>*b*", Operator:=xlAnd, Criteria3:="<>*c*", Operator:=xlFilterValues

Failing that, have you tried recording what you want as a Macro as copying/adapting the recorded code to do what you want?

如果失败,您是否尝试过将您想要的内容作为宏录制为复制/改编录制的代码以执行您想要的操作?