PDA

View Full Version : Solved: Highlight only certain words in cells



agnesz
10-15-2009, 10:58 AM
I'd like to bold and underline only certain words in my entire spreadsheet. For example, these words need to be highilghted with a bold and underline in the whole sheet:
"stormy"
"storm"
"snow"
"snowy"

Attached is the file as to better explain what I mean.

Thanks!

georgiboy
10-15-2009, 11:38 AM
Maybe something like...
Sub HighlightWords()
Dim Words As Variant, rCell As Range

Words = Array("storm", "stormy", "storms", "snow", "snowy")

For Each rCell In Range("C1:I" & Range("A" & Rows.Count).End(xlUp).Row)
For x = 0 To UBound(Words)
If InStr(LCase(rCell.Value), Words(x)) = 0 Then GoTo jump
With rCell.Characters(Start:=InStr(LCase(rCell.Value), Words(x)), Length:=Len(Words(x))).Font
.FontStyle = "Bold"
.Underline = xlUnderlineStyleSingle
End With
jump:
Next x
Next rCell

End Sub

Hope this helps.

agnesz
10-15-2009, 12:20 PM
worked like a charm
thanks!!!!!!!!!