开发者

How to Ignore wildcards in the range.find function

开发者 https://www.devze.com 2023-02-18 19:00 出处:网络
Is it possible to treat wildcards as normal chars in the range.find function. I 开发者_运维问答am searching through a list for string matches, but am running into issues, as some of the strings conta

Is it possible to treat wildcards as normal chars in the range.find function.

I 开发者_运维问答am searching through a list for string matches, but am running into issues, as some of the strings contain wild cards. Example:

List:

ab

cde

fghi

jk

?l

r = list.range.find(s, LookAt:=xlWhole)

if s = "??" this would result in r equalling "ab"

Where as I want "??" to be treated like a normal string that would only match a string of "??"

If s = "?l" I would want r to equal "?l" not "ab"


Use a ~, i.e ~?.

For your ?l, it is ~?l.

General solution:

s = Application.WorksheetFunction.Substitute(s, "?", "~?")
0

精彩评论

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

关注公众号