繁体   English   中英

Excel VBA检查其他单元格中是否包含单元格单词

[英]Excel VBA check if cell words contained in another cell

我想检查一个单元格的所有单词是否包含在另一个单元格的子单词中。

例如:

在此处输入图片说明

A1包含在B1中,但A2不包含在B1中。

以下UDF()将确定单元格Little中的所有单词是否出现在单元格Big中

Public Function AreIn(Little As String, Big As String) As Boolean
   Dim good As Boolean, aLittle, aBig, L, B

   AreIn = False
   aLittle = Split(LCase(Little), " ")
   aBig = Split(LCase(Big), " ")

   For Each L In aLittle
      good = False
      For Each B In aBig
         If L = B Then
            good = True
         End If
      Next B
      If good = False Then Exit Function
   Next L
   AreIn = True
End Function

这里的“单词”是一组不包含空格的字符。 该测试不区分大小写。 例:

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM