I am writing a code and I want to filter based on a value in a cell in the worksheet that will vary but also I want the filter to pick up on all values that are blank. This is what I have so far:
Sheets("raw data").Range("$A$1:$O$927687").AutoFilter Field:=15, Criteria1:=Array( _
Range("T1").Value, ""), Operator:=xlFilterValues
This only returns the blanks.. I tired something like
ActiveSheet.Range("$A$1:$O$927687").AutoFilter Field:=15, Criteria1:=Array( _
"", "2010"), Operator:=xlFilterValues
and that works fine. I also tried this
Sheets("raw data").Range("$A$1:$O$927687").AutoFilter Field:=15, Criteria1:= _
Range("T1").Value, Operator:=xlAnd
and it also works but whenever I try to combine the two it doesn't work.
You can use Criteria2 for Blanks.
Try:
Sheets("raw data").Range("$A$1:$O$927687").AutoFilter Field:=15, Criteria1:= _
Range("T1").Value, Operator:=xlOr, Criteria2:=""
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.