View Single Post
 
Old 04-11-2012, 09:43 AM
gvdm gvdm is offline Windows 7 32bit Office 2010 32bit
Novice
 
Join Date: Apr 2012
Posts: 2
gvdm is on a distinguished road
Default Append text to a cell with color

Hello!

I need to append to a the text of a cell (in which some of the characters are red and the others are black) the characters "hi" coloured in red.

I've tried with this code

Code:
Dim strOut As String
Dim charOut As Characters
strOut = Sheet1.Range("G8").Characters.Text
strOut = strOut + " hi"
Sheet1.Range("G8").Characters.Text = strOut 'THIS IS THE WRONG LINE

Set charOut = Sheet1.Range("G8").Characters(Sheet1.Range("G8").Characters.Count - 1, 2) 'pick the last two chars to be coloured

charOut.Font.Color = RGB(255, 0, 0)
The problem is that, when I update the cell's string with the new string, it changes the format of the cell overwriting the previous formatting..

Is there a way to append a text to a cell with it's own colour without changing the format of the rest of the cell?

Thanks in previous
Giulio
Reply With Quote