title: How to search a list in excel against list of words to filter out
body: <p>I would like to search a list to filter out if it contains certain words.</p>
  
  <p>I found this VBA script</p>
  
  <pre><code>Sub GetWords()
  
      Dim wrdLRow As Integer
      Dim wrdLp As Integer
      Dim CommentLrow As Integer
      Dim CommentLp As Integer
      Dim fndWord As Integer
      Dim Sht As Worksheet
  
      On Error Resume Next 'Suppress Errors... for when we don't find a match
  
      'Define worksheet that has data on it....
      Set Sht = Sheets("Sheet1")
  
      'Get last row for words based on column A
      wrdLRow = Sht.Cells(Rows.Count, "A").End(xlUp).Row
  
      'Get last row for comments based on column C
      CommentLrow = Sht.Cells(Rows.Count, "C").End(xlUp).Row
  
      'Loop through lists and find matches....
      For CommentLp = 2 To CommentLrow
  
          For wrdLp = 2 To wrdLRow
  
              'Look for word...
              fndWord = Application.WorksheetFunction.Search(Sht.Cells(wrdLp, "A"), Sht.Cells(CommentLp, "C"))
  
              'If we found the word....then
              If fndWord &gt; 0 Then
                  Sht.Cells(CommentLp, "D") = Sht.Cells(CommentLp, "D") &amp; "; " &amp; Sht.Cells(wrdLp, "A")
                  fndWord = 0 'Reset Variable for next loop
              End If
  
          Next wrdLp
  
          Sht.Cells(CommentLp, "D") = Mid(Sht.Cells(CommentLp, "D"), 3, Len(Sht.Cells(CommentLp, "D")) - 2)
  
      Next CommentLp
  
  End Sub
  </code></pre>
  
  <p>Before image</p>
  
  <p><a href="https://i.stack.imgur.com/zseq9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zseq9.png" alt="enter image description here"></a></p>
  
  <p>After image</p>
  
  <p><a href="https://i.stack.imgur.com/SZs3J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SZs3J.png" alt="enter image description here"></a></p>
  
  <p>It not only searches for words but also for characters inside words.</p>
  
  <p>If the string in col C is "How can i make excel to search word against a list of words?"</p>
  
  <p>and the words to look for in col A are "how, ke, cel, abcd, xyz"</p>
  
  <p>then this will return "how; ke; cel;".</p>
  
  <p>I want only "how" not the char "ke;cel;" inside the words "make;excel".</p>
  
  <p>This might be done by modifying this script, so it returns only words if it contains space either before of after the word, so it can be guessed as the whole word instead of characters. </p>