leontief
leontief

Reputation: 23

Excel VBA syntax for numeric wildcard in AutoFilter Criteria?

Example:

ActiveSheet.UsedRange.AutoFilter Field:=1, Criteria1:=12345678
ActiveSheet.UsedRange.AutoFilter Field:=1, Criteria1:=1234 & "*"
ActiveSheet.UsedRange.AutoFilter Field:=1, Criteria1:=Array(12345678, 12345679, 12345670, ...)

My sample criteria are eight-digit values beginning with 1234. The first line works, but the second and third lines return a blank sheet. I've tried seemingly countless variations of the latter two lines, none of which have come to fruition. Thanks!

Upvotes: 2

Views: 590

Answers (1)

Shai Rado
Shai Rado

Reputation: 33682

You can try the following workaround, as long as you have a consistant 8 digit structure, you can check if it's inside the value range of 12340000 and 12349999, like in the line below:

ActiveSheet.UsedRange.AutoFilter Field:=1, Criteria1:=">=12340000", Operator:=xlAnd, Criteria2:="<=12349999"

Upvotes: 2

Related Questions