+ Reply to Thread
Results 1 to 6 of 6

Format cell text based on cell colour.

Hybrid View

  1. #1
    Registered User
    Join Date
    02-14-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    3

    Format cell text based on cell colour.

    Hi,

    I need help formating a cells' text based on the cell colour.

    E.g. If cell b12 fill colour is red then a text should appear saying Service. I have already set conditional formating to determin the cell fill colour.

    Any help would be appriciated.

    Thanks

  2. #2
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: Format cell text based on cell colour.

    Option Explicit
    
    Sub sSetCF()
    With Range("B12")
        .Select
        .FormatConditions.Add _
            Type:=xlExpression, _
            Formula1:="=A12=""Red"""
        .FormatConditions(.FormatConditions.Count).SetFirstPriority
        With .FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = 255
            .TintAndShade = 0
        End With
        .FormatConditions(1).StopIfTrue = False
    End With
    End Sub
    
    Sub sSetText()
    
    With Range("B12")
        If .FormatConditions(1).Interior.Color = 255 Then
            .Value = "Service"
        End If
    End With
    End Sub

  3. #3
    Registered User
    Join Date
    02-14-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    3

    Re: Format cell text based on cell colour.

    Thanks for the reply, it worked in a manner.

    I need cells b12:j16 to say service only if they are highlighted red.

    Thanks

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Format cell text based on cell colour.

    Wrong Solution.

    Use the same formula that you use for your conditional formatting in excel.

    Use that formula to set the text to change the text to "Service"
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  5. #5
    Registered User
    Join Date
    02-14-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    3

    Re: Format cell text based on cell colour.

    Thanks for the reply I will give it a go. Much appreciated.

    What's with the please and thank you quote mehmetcik? In all my post I said thank you, I appreciate help from all willing to do so.

    Thanks RGM0

  6. #6
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: Format cell text based on cell colour.

    Wrong solution
    What did he ask for? And what did he get? I won't disagree that there are other more practical solutions, as you suggest. But, when I ask for something, I prefer to get what I ask for, not what someone else decides I should have.

    And I only explained how it could be done. Not that he must use the solution provided.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to conditional format with colour scale based on values in another cell
    By rachel1504 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-22-2015, 04:02 AM
  2. [SOLVED] Changing the colour of a cell based on PART of the text of the cell
    By Sanglorian in forum Word Programming / VBA / Macros
    Replies: 4
    Last Post: 11-11-2014, 12:48 AM
  3. Replies: 2
    Last Post: 11-29-2012, 11:27 AM
  4. [SOLVED] Macro to change text colour of adjacent cell to the same text colour as target cell
    By kayoke in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-28-2012, 04:18 AM
  5. Replies: 1
    Last Post: 05-06-2010, 03:09 AM
  6. Format Colour of Row based on Value In Cell J
    By mccrimmon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-28-2008, 11:53 AM
  7. [SOLVED] Format colour of cells based on other cell - 34 colours
    By Graham Tritton in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-13-2006, 10:10 PM

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