In the continuing saga of my data analysis (First Question), I want to delete all the rows whose departments (Field 7) are not 101, 102 or 103 (the names have been changed to protect the innocent). There are about a hundred departments in the data, so using Criteria1:=Array("104", "105", "106",
etc is impractical.
I would like to do something like this:
myrange.AutoFilter Field:=7, Criteria1:="<>101", Operator:=xlOr, _
Criteria2:="<>102", Operator:=xlOr, Criteria3:="<>103"
but Excel doesn't recognize more than 2 Criteria. I could add a helper column, and have the macro run through each line (if 101, 102, or 103, then value=Yes), filter out the yeses, and delete all that remain, but I'm saving that as a last resort.
Is there a way to Autofilter Criteria1 to be Not Equal To an array? Something like:
myrange.AutoFilter Field:=7, Criteria1:="<>" & Array("101", "102", "103")
r
is never set. Also, I'm not familiar with theUnion
function. Am I correct in assuming that it adds the current cell to the rangerDelete
? – Kush