Hans built the below code: Instead of just picking out specific words and changing the color/bold, I would like to change all the text in the the entire row to be the identified style/color.
Code: Select all
Sub FindAndHighlight2()
Const CaseSensitive = False '<-- adjust
Dim wsh As Worksheet
Dim strFind As Variant
Dim rng As Range
Dim strAddress As String
Dim CompareType As VbCompareMethod
Dim myLen As Long
Dim Posn As Long
Application.ScreenUpdating = False
If CaseSensitive Then CompareType = vbBinaryCompare Else CompareType = vbTextCompare
For Each wsh In Worksheets
With wsh.Range("D:R")
For Each strFind In Array("brad", "sam") '<-- adjust
myLen = Len(strFind)
Set rng = .Find(What:=strFind, LookAt:=xlPart, MatchCase:=CaseSensitive)
If Not rng Is Nothing Then
strAddress = rng.Address
Do
Posn = InStr(1, rng.Value, strFind, CompareType)
Do
With rng.Characters(Start:=Posn, Length:=myLen).Font
.FontStyle = "Bold" '<-- adjust
.ColorIndex = 5
End With
Posn = InStr(Posn + 1, rng.Value, strFind, CompareType)
Loop Until Posn = 0
Set rng = .FindNext(After:=rng)
Loop Until rng.Address = strAddress
End If
Next strFind
End With
Next wsh
Application.ScreenUpdating = True
End Sub
Brad