Excel Conditional Formatting with more than 3 Colors in the scale

Anonymous
2025-03-31T14:32:56+00:00

Hi Everyone,

I'm working on a project that requires me to have specific colors for certain values. I'm curious as to how I would set up conditional formatting to add the color scale I've attached to the cells I need formatted. Using the normal "Format cells based on values" option doesn't allow me to have more than three colors.

Thanks in advance!

This is a project for a meteorology class where we have to create a month long record of temperature data for the following states.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. Anonymous
    2025-03-31T14:54:45+00:00

    You need to set up 13 separate CF rules, using the Formula option. Use formulas like this:

    =AND(D3>=10,D3<20)

    and then choosde the appropriate color for that band. Then copy that cell, and paste formats over all the others.

    0 comments No comments
  2. Anonymous
    2025-03-31T15:06:15+00:00

    Hi Berine,

    Is there a way I could make that a gradient? So a temperature of 47 would be closer to the color of 50?

    0 comments No comments
  3. Anonymous
    2025-03-31T15:42:43+00:00

    Not easily. I'm not sure of the limit on the number of formula CFs, but you could try that with smaller steps.

    OR - You could identify the color based on the integer temperature - I think you could create a table of temperature values with the color as the fill for each individual temperature (all 130+ possible values), and then use a macro to read that cell's RGB settings and apply it to the values in your table.

    0 comments No comments
  4. Anonymous
    2025-03-31T16:35:22+00:00

    Yeah the thought of creating 130 CF formulas doesnt sound that appealing to me.

    Do you have any resources on how I could create such a macro? My other concern with that would be finding all 130+ values.

    0 comments No comments
  5. Anonymous
    2025-03-31T19:48:21+00:00

    The macro is below.

    First, you need to assign your colors - I have only done three, but you need to do all 130 or 65 if you want to do it by 2 degrees, but that would require slightly different code....) Those three cells with color I have named "Colors"

    Image

    Then select the Value cells, and run the macro, and this should be the result:

    Image

    Here is the macro:

    Option Explicit

    Sub ColorTemperatureValues()

    Dim rngC As Range 
    
    Dim ci As Variant 
    
    For Each rngC In Selection 
    
        ci = Application.Match(rngC.Value, Range("Colors"), False) 
    
        If Not IsError(ci) Then 
    
            rngC.Interior.Color = Range("Colors").Cells(ci).Interior.Color 
    
        End If 
    
    Next 
    

    End Sub

    And here is a macro that will at least give you a cool to warm color gradient in 130 cells in column A:

    Sub CoolToWarm()

    Dim i As Long 
    
    For i = 1 To 130 
    
        Cells(i, 1).Value = i - 11 
    
        Cells(i, 1).Interior.Color = RGB(2 \* i, 255, 255 - 1.5 \* i) 
    
    Next i 
    

    End Sub

    0 comments No comments