开发者

VBA 2010 - AutoFilter Contains Variable

开发者 https://www.devze.com 2023-02-20 19:44 出处:网络
I have this code:Range(\"$A$1:$C$118\").AutoFilter Field:=1, Criteria1:=\"=searchtex开发者_C百科t\"

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号