0

I tried to use a similar macro posted on this [topic][1]. However, when I modified to use it for a scenario that covers a list of keywords in column A (A1:A36) while the search has to be applied on every cell of Column B (B2:B100) and highlight in red and bold the words that are found in the Column B. Below is the modified macro that I used:

  Dim cl As Range
  Dim startPos As Integer
  Dim totalLen As Integer
  Dim searchText As String
  Dim endPos As Integer
  Dim testPos As Integer

 ' specify text to search.
  searchText = "system integration configuration IT"

 ' loop trough all cells in selection/range
  For Each cl In Selection

  totalLen = Len(searchText)
  startPos = InStr(cl, searchText)
  testPos = 0

  Do While startPos > testPos
  With cl.Characters(startPos, totalLen).Font
   .FontStyle = "Bold"
   .ColorIndex = 3
  End With

   endPos = startPos + totalLen
   testPos = testPos + endPos
   startPos = InStr(testPos, searchText)
   Loop

    Next cl

   End Sub

Thanks

Community
  • 1
  • 1

0 Answers0