PDA

View Full Version : [SOLVED:] *variable* in .AutoFilter Criteria



Lidder
09-16-2014, 11:48 PM
Hi,

I have the following problem:
I am using .AutoFilter in my code and the Criteria1 is taken from the UserForm, so it is given as a variable. I would like to modify the code to make it bulletproof. :) Now the code is like:

Criteria1:=A, where A is a variable. I would like to create something like:

Criteria1:=*A*, where A is still a variable. Since I can't use
"=*A*", what are my options here?

Cheers,
L.

mancubus
09-17-2014, 12:28 AM
hi.

try

"*" & A & "*"

Lidder
09-17-2014, 12:55 AM
Not working. Everything after "*" is ignored.

I think I've solved it.

A = "*" + A + "*", now I'm checking if it may cause any problems to the user.

mancubus
09-17-2014, 01:05 AM
strange. i always use this bit of code to autofilter having no problems.

concatenation operator in VBA is &
+ also works but use &

A = "*" & A & "*" / Criteria1:=A is no different than Criteria1:="*" & A & "*"

Lidder
09-17-2014, 01:18 AM
Somehow now it works, u are right. Thx for the tips. :)