vba 一个词的字符串搜索范围
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10996083/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Search range of strings for a word
提问by Peck3277
I'm trying to write a function in VBA for excel. =findval("Word",B:B), I want to search the Range B:B(these are short strings) for a word. If the word exists return Yes or No. So far I can search a string for a word but I can't get this to work over a range.
我正在尝试在 VBA 中为 excel 编写一个函数。=findval("Word",B:B),我想在范围 B:B(这些是短字符串)中搜索一个单词。如果单词存在,则返回 Yes 或 No。到目前为止,我可以在字符串中搜索一个单词,但我无法让它在一个范围内工作。
回答by lori_m
Will a worksheet function suffice?
工作表功能就足够了吗?
=IF(COUNTIF(B:B,"*"&"Word"&"*"),"Yes","No")