if else语句,其中条件与文本的子文本匹配

时间:2017-04-19 12:46:59

标签: vba

如果我在单元格中找到字符串“john”,我希望我的条件成立......并且单元格值可以是John先生或John Carter。这两种情况都应该为我的病情带来真正的价值。

我尝试了以下代码。没工作:

If ActiveCell.Value = "Benchmark report " & "*"

3 个答案:

答案 0 :(得分:1)

您可以使用=

代替Like(相等)
If ActiveCell.Value Like "Benchmark report " & "*"

在帮助文档中查找Like以获取详细信息。

答案 1 :(得分:0)

试试这个:

newsbox.js?wp-mce-4403-20160901:36 Uncaught ReferenceError: mon _url is not defined
    at HTMLDocument.<anonymous> (newsbox.js?wp-mce-4403-20160901:36)
    at i (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,utils,plupload,farbtastic&ver=4.7.3:2)
    at Object.add [as done] (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,utils,plupload,farbtastic&ver=4.7.3:2)
    at n.fn.init.n.fn.ready (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,utils,plupload,farbtastic&ver=4.7.3:2)
    at a.fn.init.n.fn.init (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,utils,plupload,farbtastic&ver=4.7.3:2)
    at a.fn.init (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,utils,plupload,farbtastic&ver=4.7.3:9)
    at n (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,utils,plupload,farbtastic&ver=4.7.3:2)
    at newsbox.js?wp-mce-4403-20160901:23
    at newsbox.js?wp-mce-4403-20160901:367

答案 2 :(得分:0)

这是在即时窗口中尝试的好方法:

?instr(1,"John carter",lcase("JOHN"),vbTextCompare)>0

然后用ActiveCell或其他范围替换硬编码值。