【发布时间】:2018-08-14 10:43:08
【问题描述】:
您好,我正在尝试编写一段代码来识别字符串 cell(2,5) = "This situation is bad" 和 cell(3,5) = "我想坐下" 包含单词“坐下”。
理想情况下,cell(2,5) 将返回 0,而 cell(3,5) 将返回 1。
我现在有
for i = 2 to 3
if LCase(cells(i,5)) like "*sit*" then
cells(2,5) = 1
end if
next i
问题是 cell(2,5) 包含单词“situation”,因此是“sit”,在这种情况下我的代码将返回 1。
我也试过
if instr(1,cells(i,5),"sit") <> 0 then
cells(i,5) = 1
它给出了同样不准确的结果
我想知道当且仅当单元格包含整个单词时,我怎样才能让某些东西返回 1?
【问题讨论】:
-
您的单词会用空格或标点符号填充吗?