Consulting

Results 1 to 2 of 2

Thread: Solved: Append text to a cell with color

  1. #1
    VBAX Newbie
    Joined
    Apr 2012
    Posts
    1
    Location

    Solved: 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
    [VBA]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)
    [/VBA]
    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Is this really solved? If so can you add the solution for the archives.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •