簡體   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