Text color in cell

  • Thread starter Thread starter Excel
  • Start date Start date
E

Excel

Any way to make one word in a cell RED with all other words black?

I am programming a macro and want one word to stand out from the others.
 
You can try this
It will make the first 5 Characters red

Range("A1").Characters(Start:=1, Length:=5).Font.Color = vbRed
 
One way to do it, if you know the start position and the
length of the word is:
ActiveCell.Character(Start:=1,Length:=2).Font.ColorIndex=3
 
Manually. Yes. Select the word in Edit mode and select the Red font.

Programmatically, more difficult. Use the Instr Function to find the
start of the string, assuming that there is only one instance of the
word in the cell.

Knowing the starting position and length of the word, ........

Watch the line wrap.

Sub ColorMe()

Dim lngStart As Long

lngStart = InStr(1, ActiveCell.Value, "Word")
ActiveCell.Characters(Start:=lngStart, _
Length:=Len("Word")).Font.ColorIndex = 3

End Sub

Tested using Excel 97SR2 on Windows 98SE,

HTH
Paul
 
Back
Top