+ Reply to Thread
Results 1 to 6 of 6

Graded Color Scale Conditional Formatting Function with Relative Access

  1. #1
    Registered User
    Join Date
    01-02-2019
    Location
    USA
    MS-Off Ver
    365
    Posts
    3

    Graded Color Scale Conditional Formatting Function with Relative Access

    Hi,

    I'm using a graded 3-color scale to format the background color for a cell, based on the value of the cell compared to another cell. For example, on the following budget worksheet, if the actual amount is less than the budget, the background should be green; if the actual amount is more, the background should be red; matching values should have a white background.
    Screen Shot 2019-01-02 at 12.13.13 PM.png

    This formatting applies to many cells, so I'd like the formula to be generic enough to copy the formatting from cell to cell, keeping the relativity of the formatting. (I'd like to be able to copy the formatting on C2 and apply it to C3, C4, etc.).

    Here's what I have so far for my 3-color-scale:

    Minimum (green): =INDIRECT(ADDRESS(ROW(), COLUMN()-1))*0.5
    Midpoint (white): =INDIRECT(ADDRESS(ROW(), COLUMN()-1))
    Maximum (red): =INDIRECT(ADDRESS(ROW(), COLUMN()-1))*1.5


    That works for everything besides when the budget and actual are both zero; in that case, it formats the background red, but it should really be white.

    My second iteration of the conditional formatting formulas was:

    Minimum (green): =IF(INDIRECT(ADDRESS(ROW(), COLUMN()-1))>0, INDIRECT(ADDRESS(ROW(), COLUMN()-1))*0.5, -100)
    Midpoint (white): =INDIRECT(ADDRESS(ROW(), COLUMN()-1))
    Maximum (red): =MAX(100, INDIRECT(ADDRESS(ROW(), COLUMN()-1))*1.5)

    However, with those applied, all the backgrounds end up being white.
    Any ideas?

    Example:
    ConditionalFormattingExample.xlsx
    Attached Images Attached Images
    Last edited by jsmartt; 01-02-2019 at 06:06 PM. Reason: Add example file

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Graded Color Scale Conditional Formatting Function with Relative Access

    People normally do not respond to posts without sample workbooks because they do not want to have to enter in data that you may already have. So, in the future, if you include a sample workbook, the post is more likely to get a response. However, this one was easy enough to set up. There are two conditions to apply, both of them of type "Use a formula."

    The first is B2 > C2 -> Green
    The second is B2 < C2 -> Red.

    By default if B2 = C2, neither condition applies and cell is left unshaded.
    Attached Files Attached Files
    Last edited by dflak; 01-02-2019 at 03:54 PM.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    01-02-2019
    Location
    USA
    MS-Off Ver
    365
    Posts
    3

    Re: Graded Color Scale Conditional Formatting Function with Relative Access

    Thanks dflak. The example you posted works, but the formatting is more simple than I'd like. If possible, I'd like to use the color scale to differentiate between values close to the budget vs far off.
    I've also updated my original post with an example file

  4. #4
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Graded Color Scale Conditional Formatting Function with Relative Access

    Please try

    Minimum (green): =INDIRECT(ADDRESS(ROW(), COLUMN()-1))-MAX($B$2:$B$6)/2

    Midpoint (white): =INDIRECT(ADDRESS(ROW(), COLUMN()-1))

    Maximum (red):=INDIRECT(ADDRESS(ROW(), COLUMN()-1))+MAX($B$2:$B$6)/2

  5. #5
    Registered User
    Join Date
    01-02-2019
    Location
    USA
    MS-Off Ver
    365
    Posts
    3

    Re: Graded Color Scale Conditional Formatting Function with Relative Access

    Thanks Bo_Ry. That's something I hadn't considered, where the scale for shading is more consistent. I think I may end up going with a solution similar to this, since although it doesn't compute the scale for each row independently, it does allow me to show which rows are far over or under the budget. Also, realistically, even though spending $15 when $10 is budgeted is 50% over budget, it doesn't make sense to draw as much attention to that as 50% over $1000.

    I'll probably end up going with something like the following, where I can define the overages/savings that constitute dark red/green without specifying any cell values/ranges:

    Minimum (green): =INDIRECT(ADDRESS(ROW(), COLUMN()-1))-100
    Midpoint (white): =INDIRECT(ADDRESS(ROW(), COLUMN()-1))
    Maximum (red): =INDIRECT(ADDRESS(ROW(), COLUMN()-1))+100

    I also figured out that a proxy cell could be used to calculate min and max values with more complicated formulas than the conditional formatting allows. I can then use the indirect addressing, but I would have to then deal with either overlooking or hiding those extra columns. I have attached a sheet with a few different solution options in case others are interested.
    ConditionalFormattingExample.xlsx

    I'll go ahead and mark this issue as solved, because I think I have a solution I'm happy with. Thanks all!

  6. #6
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Graded Color Scale Conditional Formatting Function with Relative Access

    Happy to see that you have progress
    Thank for mark topic solved.

+ 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. Replies: 8
    Last Post: 11-16-2016, 05:58 PM
  2. Replies: 6
    Last Post: 10-18-2016, 12:35 PM
  3. [SOLVED] Conditional Formatting like Color Scale but doing it via Interior.Color
    By Hyflex in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-04-2015, 06:36 AM
  4. Replies: 3
    Last Post: 10-08-2013, 09:34 AM
  5. Graded Color Scale vs Rule order
    By sam452 in forum Excel General
    Replies: 3
    Last Post: 08-02-2013, 02:58 PM
  6. Conditional formatting, three colour scale, how to use relative cell
    By marcopietro in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-12-2012, 07:38 AM
  7. Conditional Formatting 3 color scale
    By Kagesen in forum Excel General
    Replies: 15
    Last Post: 05-03-2012, 08:50 AM

Tags for this Thread

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