Results 1 to 2 of 2
  1. #1
    5 Star Lounger
    Join Date
    Jul 2002
    Hatsukaichi, Hiroshima, Japan
    Thanked 0 Times in 0 Posts

    Colour Selected Text with in a cell (Excel 97)


    I have a macro that will colour the text of a selected cell orange and make the text bold:
    <code>Sub TXTorange()

    With Selection.Font

    .Color = RGB(231, 120, 23)
    .Bold = True

    End With

    End Sub</code>
    This only works on whole cells. Is there any way to do the same thing to selected characters within a cell. When I recorded a macro it gave me ActiveCell.Characters(Start:=1, Length:=1), but I won't always be selecting the first character. I'm looking for a way to automate changing the font colour of selected text. Is there one?


    Chris (Hunt)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts

    Re: Colour Selected Text with in a cell (Excel 97)

    I don't think you can run a macro while text is selected in the formula bar or in the cell itself.

    You can use code to color parts of a cell's value, though:

    Sub ColorText()
    With Range("A1")
    .Value = "Red Orange Green"
    .Characters(Start:=1, Length:=3).Font.Color = vbRed
    .Characters(Start:=5, Length:=6).Font.Color = RGB(255, 128, 128)
    .Characters(Start:=12, Length:=5).Font.Color = vbGreen
    End With
    End Sub

Posting Permissions

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