vba 过滤掉特定值

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

Filtering Out Specific Value

excelvba

提问by James Snyder

I want to filter out a specific value in a column, but the record feature seems to only support selecting specific values to keep instead of take out.

我想过滤掉列中的特定值,但记录功能似乎只支持选择要保留的特定值而不是取出。

For example, if the column is filled with arbitrary words not known beforehand, I want to make sure a specific word is not there. If a column was filled with names of fruits, I would want to take out "apple" without having to know the name of every other fruit in there.

例如,如果该列填充了事先未知的任意单词,我想确保不存在特定单词。如果一列填满了水果的名称,我会想取出“apple”而不必知道其中的所有其他水果的名称。

I would have to select every fruit but "apple" to filter "apple" out.

我必须选择除“苹果”之外的所有水果来过滤“苹果”。

采纳答案by Gary's Student

Consider:

考虑:

Sub Macro1()
    ActiveSheet.Range("$G:$G").AutoFilter Field:=1, Criteria1:="<>apple", _
        Operator:=xlAnd
End Sub

just as an example.

只是作为一个例子。