+ Reply to Thread
Results 1 to 2 of 2

Conditional Formatting Color Scales by Category

  1. #1
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Conditional Formatting Color Scales by Category

    Hello,

    I'm trying to apply conditional formatting to a range so that it creates color scales, separately for each value in another column. For example.

    Fruit Size
    Apple 2
    Apple 3
    Apple 2
    Apple 1
    Grape 0.2
    Grape 0.3
    Melon 10
    Melon 12
    Melon 9

    I want the 2nd, 6th, and 8th lines to be green, the 4th, 5th, and 9th lines to be red, and the rest to be in between.
    I realize that I could separately set up conditional formatting for each range manually, but my dataset is large and will be changing, so I need it to be automatic.

    Thank you,
    K64
    1. Include a sample workbook with an example of the result you want
    2. Use [CODE] and [FORMULA] wrappers for your VBA code or excel formulas
    3. If your question has been answered, mark the thread as SOLVED and click on the "Add Rep" star to thank whoever helped you.

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

    Re: Conditional Formatting Color Scales by Category

    This isn't exactly conditional formatting. It's a method I had to come up with for a dashboard application that can't do color formatting. What I did was made a list of numbers from 0% to 100% in increments of 5 and then applied conditional formatting Red to Green on these values and got the RGB values of the colors. This gave me the table on the color tab. I threw in the graphical interpretation just for grins.

    Since the color chart is based on percentiles, I used a helper cell to calculate the percentile for each fruit.
    =PERCENTRANK(IF([Fruit]=[@Fruit],IF(NOT(ISBLANK([Size])),[Size],FALSE)),[@Size])
    This is an array formula, so it is entered with CTRL-SHIFT-ENTER.
    Sub ColorIt()
    Dim cl As Range

    For Each cl In Range("A2:A21")
    cl.Interior.Color = RGB(cl.Offset(0, 3).Value, cl.Offset(0, 4).Value, cl.Offset(0, 5).Value)
    Next

    End Sub
    [/code]

    Then I used the percentile to look up the RGB values.

    From there I had to apply a VBA subroutine to apply the colors
    [code]
    Attached Images Attached Images
    Attached Files Attached Files
    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.

+ 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. [SOLVED] conditional formatting -- change direction of evaluation -- using color scales (2010)
    By macrorookie in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-01-2014, 07:23 PM
  2. Copy Conditional Formatting Color Scales Excel 2007
    By catbert22 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-19-2014, 07:05 PM
  3. Replies: 0
    Last Post: 02-05-2014, 06:16 AM
  4. Replies: 4
    Last Post: 08-25-2012, 11:41 AM
  5. Conditional Formatting with Color Scales - Entire Row
    By PinkNinja in forum Excel General
    Replies: 1
    Last Post: 01-21-2011, 10:09 PM
  6. colour scales conditional formatting
    By mattianperry in forum Excel General
    Replies: 1
    Last Post: 10-15-2010, 06:43 AM
  7. Replies: 4
    Last Post: 06-14-2009, 03:10 AM

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