View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Search for text, change font color

Hi John,

See the VBA help example for the FindNext method.

Here is a minor adaptation:

Sub Tester03()
Dim sStr As String
Dim sh As Worksheet

Set sh = ActiveSheet

sStr = "widget"

With sh.Cells
Set c = .Find(sStr, _
After:=Range("A1"), _
LookIn:=xlValues, _
LookAt:=xlPart, _
MatchCase:=False)

If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Interior.ColorIndex = 3
Set c = .FindNext(c)
Loop While Not c Is Nothing And _
c.Address < firstAddress
End If
End With

End Sub

---
Regards,
Norman



"John" wrote in message
...
I would like to have Excel search through a workbook, and change the font
color of a string of text wherever it occurs in the workbook. For example
if
I'm searching for "widgets", if cell A14 contains " no widgets were sold
this week", I would like the font color of "widgets" to be red. If that
can't be done, I'll settle for the font color of all of cell A14 to be
red.
Can it be done without VBA?