|
Home > Format > Conditional > Color Scale Conditional Formatting Color Scales
|

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.
In this example, I want to enter a temperature in cell B3, and have its color change automatically.

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.
Here are the steps to set up the worksheet:

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

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
In the daily weather log file, there's also a pivot table with a conditional formatting color scale for maximum temperatures.

In the Excel file, I created a pivot table from the daily temperature data.
In the pivot table layout, I put:
Next, I grouped the Date by Year and Month.
In the pivot table layout, I moved Year to the column area
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).

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
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.

On the pivot table conditional formatting page, you can see more examples and tips.
Someone asked me if it was possible to use conditional formatting in an Excel pie chart. The chart's data had two different amounts:
From those amounts, the Percent Invoiced had been calculated.
The pie chart needed to show these things:
The completed pie chart should look something like this:

To investigate the problem, I created a small data set, similar to what the email had described.
Get the completed Chart Colour Macro workbook
Here’s a screen shot of my sample data for the 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.

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.
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
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
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.

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.

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!
Conditional Formatting Examples
Fix Conditional Formatting Extra Rules
Conditional Formatting Multiple Cells
Conditional Formatting - Currency
Last updated: May 3, 2025 3:55 PM