You need to loop rather than do the code once.
Sub Hilite()
Dim rngTextOrig As Range
Dim rngTextMatch As Range
Dim lngIndex As Long
Dim vntWord As Variant
Dim lngPos As Long
Dim lngOrigPos As Long
Set rngTextOrig = Range("A5:A10")
Set rngTextMatch = rngTextOrig.Offset(0, 1)
For lngIndex = 1 To rngTextOrig.Cells.Count
lngOrigPos = 1
For Each vntWord In Split(rngTextOrig.Cells(lngIndex).Value, " ")
lngPos = InStr(1, rngTextMatch.Cells(lngIndex).Value, vntWord, vbTextCompare)
If lngPos > 0 Then
Do While lngPos > 0
With rngTextMatch.Cells(lngIndex).Characters(lngPos, Len(vntWord))
.Font.Bold = True
.Font.Color = vbRed
End With
lngPos = InStr(lngPos + 1, rngTextMatch.Cells(lngIndex).Value, vntWord, vbTextCompare)
Loop
lngPos = InStr(lngOrigPos, rngTextOrig.Cells(lngIndex).Value, vntWord, vbTextCompare)
If lngPos > 0 Then
With rngTextOrig.Cells(lngIndex).Characters(lngPos, Len(vntWord))
.Font.Bold = True
.Font.Color = vbRed
End With
lngOrigPos = lngPos + Len(vntWord) + 1
End If
End If
Next
Next
End Sub
Bookmarks