+ Reply to Thread
Results 1 to 4 of 4

Can some words in a string be a different color?

  1. #1
    Forum Contributor
    Join Date
    11-26-2008
    Location
    Ohio
    MS-Off Ver
    2016
    Posts
    326

    Can some words in a string be a different color?

    I have some cells that change when clicked on, to different texts. "Good, Fair, Bad, and Blank". Is there a code that can be added to make the word "Bad" imput in the color red?
    My code is below.

    Thanks / Rich

    -------------------------------------------

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Const WS_RANGE As String = "A1:A300" '<=== change Range of cells to suit

    On Error GoTo err_handler
    Application.EnableEvents = False
    If Not Application.Intersect(Target, Range(WS_RANGE)) Is Nothing Then
    With Target
    .Font.Name = "Good"
    Select Case .Value
    Case "Good": .Value = "Fair"
    Case "Fair": .Value = "Bad"
    Case "Bad": .Value = ""
    Case Else: .Value = "Good"

    End Select
    .Offset(2, 0).Select
    End With
    End If
    err_handler:
    Application.EnableEvents = True
    End Sub

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,935
    Use conditional formatting.
    Ben Van Johnson

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    Use Conditional Formatting for that in the cells that these words appear. Click on Format > Conditional Formatting and set the parameters to Cell Value Is: Equal to: Bad and then click Format to setup your font formatting preference.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,972
    Try this:
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1