Public Sub ColorKeyword(tgRange As Range, KeyWord As String)
Dim rC As Range
Dim startPos As Long
Dim hitPos As Long
Dim kwLength As String
kwLength = Len(KeyWord)
For Each rC In tgRange
startPos = 1
Do
hitPos = InStr(startPos, rC.Value, KeyWord)
If hitPos > 0 Then
rC.Characters(Start:=hitPos, Length:=kwLength).Font.ColorIndex = 5
startPos = startPos + kwLength
Else
Exit Do
End If
Loop
Next
End Sub
|