gvdm
04-22-2012, 04:13 AM
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
Dim strOut As String
Dim charOut As Characters
strOut = Sheet1.Range("G8").Characters.Text
strOut = strOut + " hi"
Sheet1.Range("G8").Characters.Text = strOut
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
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
Dim strOut As String
Dim charOut As Characters
strOut = Sheet1.Range("G8").Characters.Text
strOut = strOut + " hi"
Sheet1.Range("G8").Characters.Text = strOut
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