Results 1 to 3 of 3

Thread: How to Dynamically change the Background Color of a Comment

  1. #1

    Question How to Dynamically change the Background Color of a Comment



    Register for a FREE account, and/
    or Log in to avoid these ads!

    I am looking to dynamically change the color of Comments (not Manually change the color).

    • Im using excel 2010 on Windows 7.
    • The cells in Column C use Conditional Formatting to change the background color of the cell to either Red, Yellow, Blue or Green based on data in other Columns. This coloring is my status indicator for each Row of data.
    • Each cell in Column C also has a Comment.


    I would like to have the BG color of the Comment always change to match the BG color of the Cell in which the comment resides. I can do it manually but would like to have the colors match-up automatically without the need to go into each Comment to change the color to match the current color Status of the Cells in Column C.

    My excel experience is basic so Im not sure whether this can be done via Conditional Formatting, Macros, or other methods.

    Any advice is much appreciated....

  2. #2
    Super Moderator p45cal's Avatar
    Join Date
    Dec 2012
    Posts
    1,356
    Articles
    0
    Excel Version
    365
    I don't think this can be done with conditional formats, but I have the beginnings of a solution with a macro which would include something like:
    Code:
    For Each cll In Columns(3).SpecialCells(xlCellTypeAllFormatConditions).Cells
      If Not cll.Comment Is Nothing Then
        cll.Comment.Shape.Fill.ForeColor.RGB = cll.DisplayFormat.Interior.Color
      End If
    Next cll
    but where this would go depends on how the values in column C are getting there (are they calculated?, put in manually?, cut and pasted in)?
    If you put the above code into a macro :
    Code:
    Sub blah()
    For Each cll In Columns(8).SpecialCells(xlCellTypeAllFormatConditions).Cells
      If Not cll.Comment Is Nothing Then
        cll.Comment.Shape.Fill.ForeColor.RGB = cll.DisplayFormat.Interior.Color
      End If
    Next cll
    End Sub
    and just run it, it will run through each cell in column C which has conditional formatting in, check it has a comment, then match the colour of the comment to the visible colour of the cell. It will work on the sheet which is currently active.
    So the outstanding questions to you are:
    How do these cells change their values? (via a formula or manual input)
    When do you want the comment colour to match?

  3. #3
    Hi p45cal - That worked like a charm... on the first try...! The only edit was to switch Column(8) to Column(3) to match the column I was working with.

    I was not changing the actual Values in the Column - only the BG color was changing - so the code above was perfect.

    Thanks so much p45cal for the assistance. I know where to go the next time I'm looking for help to answer an exel question...

Posting Permissions

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