RWayneH
asked on
Autofilter on cells not equal to
I am finishing an autofilter and had a late add. In the code, I need to add a line that gives me only the cells that do have the text REJ in it. There are numerous other values in the same cell, I just do not want the ones that have REJ as part of it.
With rgFilter
.AutoFilter
.AutoFilter Field:=7, Criteria1:="SPCLMDL"
.AutoFilter Field:=10, Criteria1:=Array( _
"CRTD", "PCNF LKD REL", "PCNF REL", "REL"), Operator:=xlFilterValues
.AutoFilter Field:=20, Criteria1:="<=" & Date, Operator:=xlAnd 'Late including today
.Sort Key1:=Range("T1"), Order1:=xlAscending, Header:=xlGuess, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod:=xlPinYin
'Need to filter by not-equal to REJ in column 31, if the value REJ is anywhere in any cell in this column
'Sample data is CNF REJ PCNF REL could be in any cell.
End With
On which column are you going to apply this new filter ?
Sorry, did no see you code, which already has the answer. !! My bad.
Please add the following code in the same block
.AutoFilter Field:=31, Criteria1:="=*REJ*", Operator:=xlAnd
.AutoFilter Field:=31, Criteria1:="=*REJ*", Operator:=xlAnd
ASKER
So ="=*REJ*" means not equal too? and ="*REJ*" means equal too? Can you please explain the line? It will help me understand this for future filters.. thanks. -R-
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Are you after the cells that contain only REJ and nothing else?
If so:
.AutoFilter Field:=31, Criteria1:="=*REJ*", Operator:=xlAnd, Criteria2:="<>* *"
Thanks
Rob H
If so:
.AutoFilter Field:=31, Criteria1:="=*REJ*", Operator:=xlAnd, Criteria2:="<>* *"
Thanks
Rob H
Actually just realised that if its those with only REJ it would be:
.AutoFilter Field:=31, Criteria1:="=REJ"
If the REJ could have trailing spaces then add an * after the J. This will show all cells that start with REJ.
I am guessing that you are producing a list from SAP showing Release Status of items eg Network or Activity. Can you use the Dynamic selection in SAP to generate the list with only REJ status?
Unfortuntely no longer have access to the PS module of SAP to help find the necessary criteria.
Thanks
Rob H
.AutoFilter Field:=31, Criteria1:="=REJ"
If the REJ could have trailing spaces then add an * after the J. This will show all cells that start with REJ.
I am guessing that you are producing a list from SAP showing Release Status of items eg Network or Activity. Can you use the Dynamic selection in SAP to generate the list with only REJ status?
Unfortuntely no longer have access to the PS module of SAP to help find the necessary criteria.
Thanks
Rob H
ASKER
Looking for whether "REJ" is anywhere in the contents of a cell. Ex ( REL CNF LKD REJ) would return True
If true filter it out. ( REL CNF LKD ) = False REJ not in the cell so show it. -R-
If true filter it out. ( REL CNF LKD ) = False REJ not in the cell so show it. -R-
ASKER
See the code above, I want to add this to the existing filters.. -R-
ASKER
.AutoFilter Field:=31, Criteria2:= _
"<>*REJ*", Operator:=xlAnd
is failing, when I use criteria1 it fails too... I got the line from the macro recorder. Maybe I need to understand the CriteriaX number? -R-
"<>*REJ*", Operator:=xlAnd
is failing, when I use criteria1 it fails too... I got the line from the macro recorder. Maybe I need to understand the CriteriaX number? -R-
With rgFilter
.AutoFilter
.AutoFilter Field:=7, Criteria1:="SPCLMDL"
.AutoFilter Field:=10, Criteria1:=Array( _
"CRTD", "PCNF LKD REL", "PCNF REL", "REL"), Operator:=xlFilterValues
.AutoFilter Field:=20, Criteria1:="<=" & Date, Operator:=xlAnd 'Late including today
.Sort Key1:=Range("T1"), Order1:=xlAscending, Header:=xlGuess, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod:=xlPinYin
'Need to filter by not-equal to REJ in column 31, if the value REJ is anywhere in any cell in this column
'Sample data is CNF REJ PCNF REL could be in any cell.
End With
ASKER
It was a different issue... the
.AutoFilter Field:=31, Criteria1:="<>*REJ*", Operator:=xlAnd
worked to remove the rows that REJ showed in. -R-
.AutoFilter Field:=31, Criteria1:="<>*REJ*", Operator:=xlAnd
worked to remove the rows that REJ showed in. -R-
ASKER
Thanks for the help w/ this. -R-