I have this code: Range("$A$1:$C$118").AutoFilter Field:=1, Criteria1:="=searchtex开发者_C百科t" Where searchtext needs to be a variable and am struggling to find out how to write it with a variable there.
Thanks in advance
You just need to pass the value of the variable to the 'Criteria1' parameter.
Currently you're just sending the autofilter a string literal of "=searchtext".
Example:
Dim myCriteria as String
myCriteria = "ThisIsVariable"
Range("$A$1:$C$118").AutoFilter Field:=1, Criteria1:=myCriteria
精彩评论