Text color in cell

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.
 
R

Ron de Bruin

You can try this
It will make the first 5 Characters red

Range("A1").Characters(Start:=1, Length:=5).Font.Color = vbRed
 
A

Anya

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
 
P

pfsardella

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top