ExcelPupper
Board Regular
- Joined
- Mar 2, 2020
- Messages
- 112
- Office Version
- 2019
- Platform
- Windows
I am trying to filter out data by having the criteria: on column D, it should contain either X100 or X101 and data on column E should not contain any of the ff: G1, G2, G3 but the code is having error when I run it.
VBA Code:
Sub FilterData
Dim LR As Long
'
Sheets(1).Activate
LR = Range("A" & Rows.Count).End(xlUp).Row
ActiveSheet.Range("A1:D" & LR).AutoFilter Field:=4, Criteria1:="=X101", _
Operator:=xlOr, Criteria2:="=X100"
Range("A1").Select
ActiveSheet.Range("A1:D" & LR).AutoFilter Field:=5, Criteria1:="<>*G1*" _
, Operator:=xlAnd, Criteria2:="<>*G2*", Operator:=xlAnd, Criteria3:="<>*G3*"
End Sub