如何忽略range.find函数中的通配符 [英] How to Ignore wildcards in the range.find function

查看:54
本文介绍了如何忽略range.find函数中的通配符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将range.find函数中的通配符视为普通字符.

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:

列表:
ab
cde
fghi
jk
?l

List:
ab
cde
fghi
jk
?l

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

如果 s ="??"这将导致 r 等于"ab"
我想在哪里"??"被视为仅与字符串"??"匹配的普通字符串
如果 s =?l",我希望 r 等于?l"而不是"ab"

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"

推荐答案

使用,即〜?.

对于您的?l ,它是〜?l .

一般解决方案:

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

这篇关于如何忽略range.find函数中的通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆