在AutoFilter中组合多个排除(<>)标准 [英] Combine multiple exclusion (<>) criteria in AutoFilter
本文介绍了在AutoFilter中组合多个排除(<>)标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用这个肮脏的黑客来解决我的问题:
I have worked around my issue by using this dirty hack:
' Filter managerial functions
ActiveSheet.Range("$A$1:$BW$2211").AutoFilter Field:=36, Criteria1:="<>Head*", _
Criteria2:="<>IT*", Operator:=XlAutoFilterOperator.xlAnd
ActiveSheet.Range("$A$1:$BW$2211").AutoFilter Field:=36, Criteria1:="<>Local Head*", _
Criteria2:="<>Resp*", Operator:=XlAutoFilterOperator.xlAnd
ActiveSheet.Range("$A$1:$BW$2211").AutoFilter Field:=36, Criteria1:="<>Team Lead*", _
Criteria2:="<>XB*", Operator:=XlAutoFilterOperator.xlAnd
$ b $有没有办法将这3个语句组合成一行?一旦我有一个第三个条件(Criteria3),Excel似乎有一个问题。此外,
Is there any way to combine these 3 statements into one line? Excel seems to have a problem as soon as I have a third criteria (Criteria3) in one line. Furthermore, <>Array() seems not to be supported.
推荐答案
高级过滤器可能更适合此目的。
An advanced filter might be more suitable for this purpose.
你也可以这样做:
Dim bUnion As Boolean
Dim i As Long
Dim vData As Variant
Dim rDataHide As Range
vData = Application.Transpose(ActiveSheet.Range("$AJ$1:$AJ$2211"))
bUnion = False
For i = 1 To 2211
If LenB(vData(i)) Then
If vData(i) Like Whatever Or vData(i) Like Whatever2 Then
If bUnion Then
Set rDataHide = Union(rDataHide, ActiveSheet.Range("$AJ$" & i))
Else
Set rDataHide = ActiveSheet.Range("$AJ$" & i)
bUnion = True
End If
End If
End If
Next i
rDataHide.Rows.Hidden = True
你甚至可以使用RegEx,我以前没有真正使用过RegEx虽然如此,你会有e to google it。
You could even use RegEx, I haven't really used RegEx much before though so you would have to google it.
这篇关于在AutoFilter中组合多个排除(<>)标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文