Home > Format > Conditional > Color Scale

Conditional Formatting Color Scales

Debra Dalgleish - Contextures

Use Excel conditional formatting formula color scales to emphasize high or low values in a list. For example, quickly spot the hottest and coldest days, or the months with the highest and lowest sales.

Pivot Table Color Scale red white blue

1) Show Temperatures With a Color Scale

In this video, I show the steps for using a conditional formatting color scale on a temperature cell. There are written steps below the video.

Show Temperatures With a Color Scale

In this example, I want to enter a temperature in cell B3, and have its color change automatically.

  • If it's very hot, the cell should be dark red
  • If it's really cold, the cell should be dark blue.

conditional formatting color scale

Use a Color Scale

To make this happen, without needing macros, I used a hidden column of numbers, and a conditional formatting color scale.

To quickly show hot temperatures in a red cell, and cold temperatures in a blue cell, you can use Excel's conditional formatting color scale.

Set Up the Numbers

Here are the steps to set up the worksheet:

  • First, enter any temperature in cell B3
  • Next, in cells F6:F25, enter the numbers from 140 down to -50, in increments of 10

Add Formulas

  • In cell G6, enter the following formula:
    • =IF($B$3=F6,"",IF(AND($B$3>F6,$B$3<F5),"",F6))
    • The result is an empty string if the current temperature is:
      • equal to the temperature in that row
      • or between that temperature, and the one above
  • Copy the formula down to row 25

Add Conditional Formatting Color Scale

  • Next, select cell B3
  • Then, press the Ctrl key, and select cells G6:G25 (the cells with the formulas)
  • On the Ribbon's Home tab, click Conditional Formatting
  • Click Color Scales, then click on the Red - White - Blue scale

conditional formatting color scale

Test the Color Scale

  • Change the temperature in cell B3
  • The cell color will change, based on the color scale.
  • (optional) Hide columns F:G, so the color scale is not visible.

2) Highlight Weather Data

In this conditional formatting example, temperatures and weather descriptions are highlighted in a weather log.

In the weather log table,

  • a Red-White-Blue color scale is used on the Temperature column.
  • In the weather column, there are 4 rules set up, to colour the cells based on weather type - Sun, Cloud, Rain or Snow.

In another worksheet, there are 2 named Excel tables - one for weather types, and one for weather descriptions.

There are also 3 named ranges, shown in the screen shot below

The named ranges are used as the source for data validation drop down lists, like this list with weather descriptions.

The named ranges are also used in the INDEX/MATCH formulas in the conditional formatting rules.

This screen shot shows the formula in a worksheet cells, where it was used for testing the formula, before creating the rule.

Note: A blank cell or cells with text, will not be affected by the color scale formatting.

Here are the 5 rules, listed in the Rules Manager.

To see the data, and test the conditional formatting, get the weather data sample file

3) Pivot Table Color Scale

In the daily weather log file, there's also a pivot table with a conditional formatting color scale for maximum temperatures.

Pivot Table Color Scale red white blue

Create a Pivot Table

In the Excel file, I created a pivot table from the daily temperature data.

In the pivot table layout, I put:

  • Date in the Rows area
  • Max temperature in the Values area

Next, I grouped the Date by Year and Month.

In the pivot table layout, I moved Year to the column area

Add Conditional Formatting

The next step was to add conditional formatting to all the temperature values, so it’s easy to spot the hot days, and cold days.

I selected all the temperature values, and applied the Red – White – Blue Color Scale option.

With that option, the high number are red (hot), and low numbers are blue (cold).

Red – White – Blue Color Scale option

Adjust Conditional Formatting Rule

If you apply conditional formatting to a pivot table, there’s an extra step to do, and the video below shows you that step.

In the short video below, I show how to go into the Conditional Formatting Rules, and change the “Apply Rule To” setting, so it refers to the pivot field names, instead of the cell addresses

Pivot Table Example 2 - Music by Decade

In the screen shot below, I created a pivot table with a 2-color scale, in green and white.

It's based on a list of the top 100 Canadian music singles, and you can download my file, to see the data and pivot table.

There are written steps on my Contextures blog.

pivot table with green-white color scale

On the pivot table conditional formatting page, you can see more examples and tips.

4) Pie Chart Colour Macro

Someone asked me if it was possible to use conditional formatting in an Excel pie chart. The chart's data had two different amounts:

  • total order amount per customer
  • total amount that had been invoiced per customer

From those amounts, the Percent Invoiced had been calculated.

The pie chart needed to show these things:

  • slice size based on the order amount
  • slice colour based on a colour scale for the % invoiced

The completed pie chart should look something like this:

client invoice data pie chart

Sample Data

To investigate the problem, I created a small data set, similar to what the email had described.

Get the completed Chart Colour Macro workbook

  • First column had client names
  • Second column showed total order amount
  • Third column had the total amount invoiced
  • Final column calculated the percent invoiced, with a simple formula:
    • Invoice Amount / Orders amount
  • Conditional formatting was applied in column E (% Inv), using a color scale (Green-Yellow-Red)

Here’s a screen shot of my sample data for the pie chart.

  • It has 11 Client names – the same number that the email question had used.
  • The highest % Invoiced cell is for Ann – it’s dark green, because that’s a good value.
  • The lowest % Invoiced is for Hal, and it’s dark red, because that’s a bad thing!

client invoice data with conditional formatting

Build a Pie Chart

Using the steps on the Pie Chart Examples page, I built a simple 2-D pie chart, using the client names, and the % Inv numbers.

I removed the legend, and the chart title, and added data labels, to show the client names.

The slices were the correct size, but the colours in each slice need to be changed. They should match the conditional formatting colour for each client's % Inv percentage cell.

pie chart with client name labels

Pie Chart Colour Match Macro

There's no built-in way to match a pie slice colour to a cell's condtional formatting colour, so I wrote a macro to do the job.

  • The macro gets the location of the source data, based on the formula for the chart series.
  • Then, the macro gets the conditional formatting color from the 3rd column to the right of the source data’s start column, by using the DisplayFormat property for the cell
  • That color is used to colour the applicable pie chart slice

Macro VBA Code

Here is the VBA code, and it's also available in the sample file you can download. The sample file also has a bar chart on the worksheet, and the macro colours its bars too.

Sub ColorChartDataPoints()
'colour data point based on
'value in rank column
Dim ws As Worksheet
Dim ch As ChartObject
Dim ser As Series
Dim dp As Point
Dim ptnum As Long
Dim rngSD01 As Range
Dim strF  As String
Dim strRng  As String
Dim CharStart As Long
Dim CharEnd As Long
Dim ColOff As Long
Dim PtColor As Long

ColOff = 3  'offset to Rank column
Set ws = ActiveSheet

For Each ch In ws.ChartObjects
  Set ser = ch.Chart.FullSeriesCollection(1)
  strF = ch.Chart.SeriesCollection(1).Formula
   
  CharStart = InStr(1, strF, ",")
  CharEnd = InStr(InStr(1, strF, ",") _
        + 1, strF, ",")
  strRng = Mid(strF, CharStart + 1, _
         CharEnd - CharStart - 1)
  Set rngSD01 = ws.Range(strRng)
  ptnum = 1
  
  For Each dp In ser.Points
    PtColor = rngSD01.Cells(ptnum, 1) _
        .Offset(0, ColOff).DisplayFormat.Interior.Color
    dp.Format.Fill.ForeColor.RGB = PtColor
    ptnum = ptnum + 1
  Next dp
Next ch

End Sub

Running the Macro

The macro runs automatically, if any changes are made in the named range, "ClientAmts". The following event code is on the worksheet code module for the sheet named Chart

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("ClientAmts")) Is Nothing Then
  ColorChartDataPoints
End If
End Sub

The Final Result

Here’s the completed Conditional Formatting Color report, with the sample data, the bar chart, and the pie chart.

It was an interesting challenge, and you can download the workbook (below), if you’d like to test it.

completed conditional formatting color report

Get the Excel Files ✅

Temperatures: Download the Temperatures color scales sample file, for the example from this page. The zipped Excel file is in xlsx format, and does not contain any macros.

Weather Data: Get the weather data sample file, with color scales for daily temperatures, and a pivot table with color scales. The zipped file is in xlsx format, and does not contain macros

Pie Chart: Get the sample Excel Chart Colour Macro workbook, with VBA macro that changes a pie chart and bar chart colours, based on a rank with color scale applied. The zipped file is in xlsm format, and contains macros

Music Pivot: Get the Top 100 Canadian Singles list, and create your own pivot table, with conditional formatting color scales. The zipped file is in xlsx format, and does not contain macros. There are written steps on my Contextures blog, for grouping the data by decade, and adding the color scale.

pivot table with green-white color scale

Get Monthly Excel Tips!

Don't miss my monthly Excel newsletter! You'll get quick tips, article links, and a bit of fun. Add your email, and click Sign Up.

Next, when you get my reply, click the Confirm button. I add this step to protect you from spam!

More Tutorials

Conditional Formatting Intro

Icon Sets

Conditional Formatting Examples

Fix Conditional Formatting Extra Rules

Conditional Formatting Multiple Cells

Conditional Formatting - Currency

Conditional Formatting Documentation

Conditional Formatting Data Bars

Last updated: May 3, 2025 3:55 PM