MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Colour text

Posted by Pete on December 06, 2001 3:57 AM

Ok if i have a formula that i wish to have part the answr in red not black text any way ti do this please

Say ="Today is : " & NOW() i would like the date in red??

Anyone know, please

Posted by Paul on December 06, 2001 4:05 AM

Format the cell text as red

Posted by Pete on December 06, 2001 4:08 AM

Re: Format the cell text as red

thats teh point dont work i only want PART the answer in red as i described formatting " RED will make all red, i cant seem to get format font to red in PART of the selection??
Im lost on this one..

Posted by Bruno on December 06, 2001 4:48 AM

pete, I don't think it's possible to format a cell with a function...
Can't you split the formula ?
for example :
cell a1 : Today is :
cell b1 : Now()

Now you can format B1 as red

Posted by Tom Urtis on December 06, 2001 5:03 AM

To format characters separately in same cell...

You say you want to have the text "Today is" in black and the date in red. Assuming your date is in mm/dd/yy format (8 characters), then invoke this code:

Sub EditCell()
With ActiveCell
.Font.ColorIndex = 3
.Characters(1, _
(ActiveCell.Characters.Count - 8)) _
.Font.ColorIndex = 1
End With
End Sub

If your date format is other than 8 characters, change the numeral 8 in the code to however many characters your date is formatted to be.

As you can probably tell, the second With structure statement is broken out onto 3 lines for easier readability here; it can go onto 1 line in your actual module for easier readability there.


Tom Urtis

Posted by Jack on December 06, 2001 7:07 AM

Re: To format characters separately in same cell...

Good stuff. ill give it a spin, guess by function will be impossible, shame but VBA gets arround that so im very happy, cheers!