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
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.
You could also do something like this:
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
You could even use RegEx, I haven't really used RegEx much before though so you would have to google it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With