close

Hi, I need to do a search and replace in a worksheet. When I match a string,
I want to change the color.

For example, if the string is
quot;Hello everyone!quot;

I want to search for any word that starts and ends with 'e', then change the
word color to be blue.

Is this possible with a cell formula? Do I need a sheet macro? I cant seem
to figure it out with either!

Thanks in advance for any help! (Office 2003)

What you are asking cannot be done with formulas. Neither with
conditional formatting, because you want formatting at text and not
cell level.

The following marco will highlight the word srch in all cells in the
range C110 of Sheet1:

Sub Highlight(srch As String)
Dim dta As Range, c As Range

Set dta = Sheets(quot;Sheet1quot;).Range(quot;C110quot;)
For Each c In dta
If InStr(1, c.Value, srch) Then
With c.Characters(Start:=InStr(1, c.Value, srch),
Length:=Len(srch)).Font
.ColorIndex = 41
End With
End If
Next c
End Sub

HTH
Kostis VezeridesNo it doesn't

quot;vezeridquot; wrote:

gt; What you are asking cannot be done with formulas. Neither with
gt; conditional formatting, because you want formatting at text and not
gt; cell level.
gt;
gt; The following marco will highlight the word srch in all cells in the
gt; range C110 of Sheet1:
gt;
gt; Sub Highlight(srch As String)
gt; Dim dta As Range, c As Range
gt;
gt; Set dta = Sheets(quot;Sheet1quot;).Range(quot;C110quot;)
gt; For Each c In dta
gt; If InStr(1, c.Value, srch) Then
gt; With c.Characters(Start:=InStr(1, c.Value, srch),
gt; Length:=Len(srch)).Font
gt; .ColorIndex = 41
gt; End With
gt; End If
gt; Next c
gt; End Sub
gt;
gt; HTH
gt; Kostis Vezerides
gt;
gt;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()