Contextures

Format > Conditional Format > Examples

Excel Conditional Formatting Examples

Excel conditional formatting formula examples. Highlight expiry dates, colour if duplicate, COUNTIF, high or low values, hide or show values, and many more examples

duplicate records highlighted

Conditional Formatting IF Formula

Question: In conditional formatting rules, do you need to use the Excel IF function to compare cells to other cells?

Answer: No, you do NOT need to use IF formulas in the Conditional Formatting rules.

Test Formula - TRUE or FALSE

In the Conditional Formatting, above the formula box, you'll see this label:

  • Format values where this formula is true

In the formula box, enter a formula to test something, like the Highlight Expired Dates example, hown below. It checks if a date is less than today's date:

  • =B2<TODAY()

format values where this formula is true

Formatting Applied if TRUE

The conditional formatting is only applied to the cells where that test result is TRUE.

  • In the screen shot below, the current date is August 23rd.
  • Dates earlier than August 23rd are coloured red with conditional formatting.
  • Other dates are not formatted

apply conditional formatting if formula result is TRUE

Highlight Dates πŸ“†

The following examples use conditional formatting formulas to highlight dates in a list.

1 -- Highlight Upcoming Expiry Dates

2 -- Highlight Expired Dates

3 -- Highlight Weekend Dates

4 -- Separate Dates With Top Border Lines

1) Highlight Upcoming Expiry Dates

You can use Excel conditional formatting to highlight payments that are due in the next thirty days. In this example, Due dates are entered in column A.

  • If the date is within the next 30 days, the date is formatted with bold blue font.
  • In column B, a formula (shown below) calculates the number of days away each date is, based on the current date.

highlight payments that are due in the next thirty days

To set up the conditional formatting for upcoming expiry dates, follow these steps

  1. Select cells A2:A9
  2. On the Ribbon's Home tab, click Conditional Formatting, then click New Rule
  3. Click Use a Formula to Determine Which Cells to Format
  4. For the formula in cell B2, use the TODAY function, with the AND function to calculate the number of days in the past or future:
    •    =AND(A2-TODAY()>=0,A2-TODAY()<=30)
  5. Click the Format button.
  6. Select formatting options (Bold, Blue font, in this example), click OK
  7. Click OK to close the dialog box

2) Highlight Expired Dates

You can use Excel conditional formatting to highlight policies with dates that have expired. In this example, due dates are entered in cells B2:B7.

  • If the date is before the current date, the date cell is formatted with red fill colour.
  • The conditional formatting formula is shown below the screen shot.

Highlight Expired Dates

To set up the conditional formatting for past expiry dates, follow these steps

  1. Select cells B2:B7
  2. On the Ribbon's Home tab, click Conditional Formatting, then click New Rule
  3. Click Use a Formula to Determine Which Cells to Format
  4. For the formula, use the Today function to find expired dates:
       =B2<TODAY()
  5. Click the Format button.
  6. Select formatting options (Red fill color, in this example), click OK
  7. Click OK

3) Highlight Weekend Dates

To highlight the weekend dates in a list, you can use conditional formatting. The WEEKDAY function returns a number for each day of the week, so you could adjust this formula to highlight other days of the week.

You can see the steps in this video, and there are written steps below the video

Highlight Weekend Dates

In this example, the Excel file has a list of product sales for the first half of July. We’d like to highlight the dates and sales numbers that fall on a weekend.

Conditional formatting will colour the cells in columns A, B and C light green, for rows with a weekend date (Saturday or Sunday).

product sales dates

To set up the conditional formatting for weekend dates, follow these steps

  • On the Ribbon, click the Home tab, then click Conditional Formatting.
  • Click New Rule, to open the New Formatting Rule dialog box
  • In the Select a Rule Type list, click Use a formula to determine which cells to format.
  • In the Formula box, enter a WEEKDAY formula to check the weekday of the date in row 2, which is the active row on the worksheet:
  • Click the Format button, and select a Fill colour, or other formatting options, then click OK.
  • Click OK to close the New Formatting Rule dialog box

The weekend rows are highlighted in light green fill colour

weekend sales rows with light green fill colour

4) Separate Dates With Lines

If you’re working with a list of tasks or orders, sorted by date, use conditional formatting to separate the dates with a border line.

You can see the steps in this video.

Format Duplicates πŸ”

The following examples show how to use conditional formatting formulas to work with duplicates in a list. Highlight duplicate values, to spot potential problems, or hide duplicate headings, to make a list easier to read.

1 -- Highlight Duplicates in Column

2 -- Highlight Duplicate Records in a List

3 -- Hide Duplicate Headings in List

1) Highlight Duplicates in Column

Use Excel conditional formatting to highlight values that are duplicate entries in a specific column, or in a range of cells (multiple rows and columns).

To highlight all the duplicate values, follow these steps:

  1. Select the cells to format -- range A2:A7 in this example
  2. On the Ribbon's Home tab, click Conditional Formatting
  3. Click Highlight Cell Rules, then click Duplicate Values
  4. In the Duplicate Values dialog box, the default format is Light Red Fill with Dark Red Text
  5. If you prefer, select one of the other formatting options from the drop down list -- I selected Light Red Fill for this example
    • Tip: For more formatting options, click the Custom Format command
  6. Click the OK button, to apply the conditional formatting.

highlight duplicate values

On the worksheet, duplicate numbers in column A are highlighted with light red fill colour.

duplicate values with light red fill

2) Highlight Duplicate Records in a List

To highlight the duplicate records in a list, you can use conditional formatting. Add a formula in one column first, to string all the data together.

You can see the steps in this video, and the written instructions are below the video.

Highlight Duplicate Records in a List

You can use Excel conditional formatting to highlight duplicate records in a list.

First, you'll set upe a formula to combine all the fields into one column, then test that column for duplicates.

duplicate records highlighted

Combine Date with Formula

First, create a formula to combine the data:

  1. In this example, the data is in cells A2:F8
  2. In cell G1, add the column heading "AllData"
  3. In cell G2, enter the formula to combine all the data:
    =CONCATENATE(A2,B2,C2,D2,E2,F2)
  4. Copy the formula down to the last row of data

Highlight Duplicate Records

Next, follow these steps, to add the conditional formatting which will format values that are duplicates:

  • Select the cells to format -- range A2:F8 in this example
  • On the Ribbon's Home tab, click Conditional Formatting
  • Next, click New Rule, to open the New Formatting Rule dialog box
  • Click Use a Formula to Determine Which Cells to Format
  • For the formula, enter use COUNTIF function (see notes below)
    • =COUNTIF($G$2:$G$8,$G2)>1
  • Click the Format button.
  • Select a font colour for highlighting - light red fill in the screen shot below.
  • Click OK, click OK

COUNTIF Formula Notes

1) Occurrences: The COUNTIF function counts the occurrences of each row's combined text, starting from row 2, and down to the formula's row. If there is more than one occurence, the row is highlighted.

2) Character Limit: The COUNTIF function only works for 255 characters or fewer. For longer strings use the following formula:

  • =COUNT(FIND($G5,$G$5:$G$11))>1

3) First Instance: If you only want to highlight the duplicate records, and not the first instance of a duplicated record, use the following conditional formatting formula:

  • =COUNTIF($G$2:$G2,$G2)>1

first instance not highlighted

3) Hide Duplicate Values

Use Excel conditional formatting to hide duplicate headings on a worksheet, to make a list easier to read. This video shows you the steps, and the written instructions are below the video.

Hide Duplicate Values

In a table, each row should have all data entered, to enable sorting and filtering. However, you can use Excel conditional formatting to hide the duplicate values, and make the list easier to read.

In this example, when the table is sorted by Region, the second (and subsequent) occurrences of each region name will have white font colour.

white font colour hides text

You can see the text if you select the cells.

white font colour shows when selected

Follow these steps to hide the duplicates, and you can see the steps in the video above.

  1. Select range A2:A5
  2. On the Ribbon's Home tab, click the Conditional Formatting button, then click New Rule
  3. Click Use a Formula to Determine Which Cells to Format
    • NOTE: In Excel 2003, choose Format|Conditional Formatting
    • Then, from the first drop-down, choose Formula Is
  4. For the formula, enter
    =A2=A1
  5. Click the Format button.
  6. Select a font colour to match the cell colour.
  7. Click OK, click OK

Highlight Numbers in List 🌑

The following examples show different ways to highlight numbers with conditional formatting rule.

1 -- Highlight Top or Bottom Values

2 -- Highlight Lottery Numbers

3 -- Highlight Weather Data

4 -- Show Temperatures With Color Scale

1) Highlight Top or Bottom Values

In these two examples, see how to highlight the:

Both examples use the same list -- the months of the year, and the quantity sold each month.

monthly sales

This video shows the steps, and the written instructions are below the video.

Top 3 Values

In this example, we'll highlight the 3 highest value cells in the list of monthly sales.

The new conditional formatting rule will use the LARGE function, which has 2 arguments:

  • the list of numbers to check -- $C$2:$C$13
  • the nth largest number to return -- 3

The rule will compare each number in the selected cells (C2:C13), to see if it is greater than or equal to that nth number

  • C2>=LARGE($C$2:$C$13,3)

Follow these steps to apply the conditional formatting:

  1. Select the numbers in the Sales column (C2:C13)
  2. On the Ribbon's Home tab, click Conditional Formatting, then click New Rule
  3. In the New Formatting Rule dialog box, in the Select a Rule Type section, click Use a Formula to Determine Which Cells to Format
  4. In the formula box, enter the LARGE formula,
       =C2>=LARGE($C$2:$C$13,3)
  5. Click the Format button.
  6. Select formatting options (light green fill), click OK
  7. Click OK

highlight top 3 values

Bottom X Values

In this example, we'll highlight the lowest numbers in the list of monthly sales. Instead of typing a specific number in the formula, we'll set up a cell on the worksheet, where that number can be entered. Then, the conditional formatting formula will refer to that cell.

First, set up the number cell:

  • In cell E1, type the heading: How Many?
  • In cell E2, type the number 2 -- that can be changed at any time later
  • Put a border around the 2 cells, centre horizontally, and add yellow fill colour in E2

TIP: Later, you could type a zero, to temporarily remove any highlighting

how many numbers to highlight

To highlight the bottom values, the conditional formatting rule will use the SMALL function, which has 2 arguments:

  • the list of numbers to check -- $C$2:$C$13
  • the nth smallest number to return -- a reference to cell $E$2

The rule will compare each number in the list, to see if it is less than or equal to that nth number

  • C2<=SMALL($C$2:$C$13,$E$2)

Next, follow these steps to apply the conditional formatting:

  1. Select the numbers in the Sales column (C2:C13)
  2. On the Ribbon's Home tab, click Conditional Formatting, then click New Rule
  3. Click Use a Formula to Determine Which Cells to Format
  4. In the formula box, enter the SMALL formula,
       =C2<=SMALL($C$2:$C$13,$E$2)
  5. Click the Format button.
  6. Select formatting options (light orange fill, or choose a red color), click OK
  7. Click OK

Bottom X numbers highlighted

To test the conditional formatting:

  • Type a different number in cell E2, to change the number of cells that are highlighted
  • Delete the number in cell E2, or type a zero, so that none of the numbers are highlighted

2) Highlight Lottery Numbers

You can use Excel conditional formatting to highlight the ticket numbers that have been drawn in a lottery. Winning numbers are entered on the sheet, and those numbers are highlighted in the list of purchased tickets. Written instructions are below the video, and you can download the sample file to follow along with the video.

Highlight Lottery Numbers

You can use Excel conditional formatting to highlight the ticket numbers that have been drawn in a lottery, or the tickets that have 3 or more winning numbers.

In this example the ticket numbers are in cells C6:H8, and the drawn numbers are entered in cells C3:H3.

If a ticket cell's value is found in the cells with drawn numbers, the ticket number cell will be highlighted in green.

highlight the ticket numbers that have been drawn in a lottery

To highlight the winning numbers:

  1. Select cells C6:H8
  2. On the Ribbon's Home tab, click Conditional Formatting, then click New Rule
  3. Click Use a Formula to Determine Which Cells to Format
  4. For the formula, use the CountIf function:
       =COUNTIF($C$3:$H$3,C6)>=1
  5. Click the Format button.
  6. Select formatting options (green fill, in this example), click OK
  7. Click OK

To highlight the winning tickets:

  1. Select cells B6:B8
  2. On the Ribbon's Home tab, click Conditional Formatting, then click New Rule
  3. Click Use a Formula to Determine Which Cells to Format
  4. For the formula, use the SUM and COUNTIF functions:
       =SUM(COUNTIF($C6:$H6,$C$3:$H$3))>=3
  5. Click the Format button.
  6. Select formatting options (yellow fill, in this example), click OK
  7. Click OK

3) Highlight Weather Data

In this conditional formatting example, temperatures and weather descriptions are highlighted in a weather log. You can download the sample data below.

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.

You can download the Conditional Formatting for Weather Data sample data below.

4) Show Temperatures With a Color Scale

To see the steps for using a color scale on a temperature cell, please watch this short video. The written instructions are below the video.

Show Temperatures With a Color Scale

To show hot temperatures in a red cell, and cold temperatures in a blue cell, you can use Excel's conditional formatting color scale. This feature is available in Excel 2007 and later versions.

conditional formatting color scale

  1. Enter the temperature in cell B3
  2. In cells F6:F25, enter the numbers 140 to -50, in increments of 10
  3. In cell G6, enter a formula that will show an empty string if the current temperature is equal to the temperature in that row, or between that temperature, and the one above:

    =IF($B$3=F6,"",IF(AND($B$3>F6,$B$3<F5),"",F6))

  4. Copy the formula down to row 25
  5. Select cell B3, then press the Ctrl key and select cells G6:G25 (the cells with the formulas)
  6. On the Ribbon's Home tab, click Conditional Formatting
  7. Click Color Scales, then click on the Red - White - Blue scale
  8. Change the temperature in cell B3, and the cell color will change, based on the color scale.
  9. (optional) Hide columns F:G, so the color scale is not visible.

    conditional formatting color scale

Show or Hide Data

The following examples show how to hide data, or show it, based on conditional formatting formula rules.

1 -- Hide Cell Contents When Printing

2 --Hide Errors

3 --Hide Follow-Up Questions

1) Hide Cell Contents When Printing

In the following example, use Excel conditional formatting to hide cells when printing. In this example, the contents of cells B2:F4 are changed to white font, if cell H1 contains an x.

Hide Cell Contents When Printing

To print with the cell contents hidden, type an x in cell H1. To display the cell contents, delete the x in cell H1.

  1. Select cells B2:F4
  2. On the Ribbon's Home tab, click Conditional Formatting, then click New Rule
  3. Click Use a Formula to Determine Which Cells to Format
    • NOTE: In Excel 2003, choose Format|Conditional Formatting
    • Then, from the first drop down, choose Formula Is
  4. For the formula, enter    =$H$1="x"
  5. Click the Format button.
  6. Select formatting options (white font and white pattern, in this example)
  7. Click OK, click OK

2) Hide Errors

You can use Excel conditional formatting to check for error values in your spreadsheet, and change the font colour to match the cell colour.

In this example, if column A contains a zero, the #DIV/0! error value is displayed in column C.

  1. Select cells C2:C5
  2. On the Ribbon's Home tab, click Conditional Formatting, then click New Rule
  3. Click Use a Formula to Determine Which Cells to Format
    • NOTE: In Excel 2003, choose Format|Conditional Formatting
    • Then, from the first drop-down menu, choose Formula Is
  4. In the rule box, enter a formula that refers to the active cell in the selection. In this example, we selected C2:C5, and cell C2 is the active cell, so we'll check for an error in cell C2.
       =ISERROR(C2)
    or, to hide only #N/A errors: =ISNA(C2)

    ISERROR formula

  5. Click the Format button.
  6. Select a font colour to match the cell colour.
  7. Click OK, click OK

3) Hide Follow-Up Questions

In this example, there is a short questionnaire, and some of the questions have a follow-up item. The follow-up question might appear, based on the first answer.

At first, only the main questions are visible. The follow-up items are in white font with white fill.

For example, "Do you have dependents?"

  • If you select No, nothing happens.
  • If you select Yes, and the next question appears.

To set this up:

  • Follow-up cells have simple conditional formatting rules, such as: =E2="Yes"
  • The conditional formatting adds a black font, fill colour, and a border.

For step-by-step video and written instructions, see my Hidden Questions blog post. The sample file is in the download section, below.

show hidden questions with conditional formatting

Highlight for Cell Content πŸ“

The following examples show how to highlight cells based on thier content.

1 -- Colour Cells Based on 2 Conditions

2 -- Highlight Cells With Formulas

3 -- Highlight Items in a List

4 -- Cross Off Completed Items

1) Colour Cells Based on 2 Conditions

Use Excel conditional formatting to colour cells if 2 conditions are met. In this example, a country code is entered in cell B2. If the code "US" is entered, cells that contain "United States" are coloured red.

data entry cells coloured red

Enter the Conditions

You could enter the conditions in the conditional formatting formula, but if you enter them in worksheet cells it's easier to see the conditions, and change them, if necessary.

In this example, the conditions are on the same sheet as the data entry cells, but you can store them on a different sheet. You could also name the cells, and use those names in the conditional formatting formula

To set up the conditions:

  • In cell E1, type Cond01
  • In cell B2, type US.
  • In cell D1, type Cond02
  • In cell D2, type United States

set up the conditions

Add the Country Code Cell

Next, set up the cell where a country code can be entered:

  • In cell B1, type Code
  • In cell B2, type US. (This can be changed later)
  • Format cell B2 with yellow fill colour, to show that it is a data entry cell

cell where a country code can be entered

Add Conditional Formatting

Next, add conditional formatting to country cells in the data range. The formula is explained below.

  1. Select cells D5:D14, where the country names are listed for the orders
  2. On the Ribbon's Home tab, click Conditional Formatting, then click New Rule
  3. Click Use a Formula to Determine Which Cells to Format
  4. For the formula, enter    =AND($B$2=$E$2,D5=$F$2)
  5. Click the Format button.
  6. Select formatting options (red fill colour, in this example)
  7. conditional formatting rule
  8. Click OK, click OK

If US is entered in cell B2, and a cell in D5:D14 contains "United States", it is coloured red.

data entry cells coloured red

How It Works

The conditional formatting formula is: =AND($B$2=$E$2,D5=$F$2)

The AND function checks the 2 conditions:

  1. Does cell B2 match the condition entered in cell E2
  2. Does the data entry cell match the condition entered in cell F2

Some notes about the cell references in the formula:

  • Cell D5 is used in the formula, because that was the active cell when the conditional formatting was applied.
  • A relative reference is used for the data entry cell (D5), because it should adjust to match each cell where the conditional formatting is applied.
  • Absolute references are used for $B$2, $E$2 and $F$2 because no matter where the conditional formatting is applied, it should always check those cells.

2) Highlight Cells With Formulas

Use Excel conditional formatting to highlight cells that contain a formula. In this example, there are values in cells A2:B8, and totals in cells C2:C8 and in A9:C9

  1. Select all the cells where you want the formatting -- range A2:C9
  2. On the Ribbon's Home tab, click Conditional Formatting, then click New Rule
  3. Click Use a Formula to Determine Which Cells to Format
  4. For the formula, enter: =ISFORMULA(A2)
  5. Click the Format button.
  6. Select a font colour for highlighting.
  7. Click OK, click OK

highlight formula cells

3) Highlight Items From Criteria List

Use Excel conditional formatting to highlight cells that contain values from a different list on the worksheet, such as a criteria list with valid two-digit codes..

In this screen shot, a list in column C has 3 code: AA, BB and CC. In column A, cells with those codes are changed to green color, thanks to a conditional formatting rule.

highlight items that are in a list

  1. Create a list of items you want to highlight. If the items are on a different sheet than the conditional formatting, name the list.
  2. Select range A2:A7
  3. On the Ribbon's Home tab, click Conditional Formatting, then click New Rule
  4. Click Use a Formula to Determine Which Cells to Format
    • NOTE: In Excel 2003, choose Format|Conditional Formatting
    • Then, from the first drop-down, choose Formula Is
  5. For the formula, enter
    =COUNTIF($C$2:$C$4,A2)
    or, if the list is named, use the name in the formula:
    =COUNTIF(CodeList,A2)
  6. Click the Format button.
  7. Select a font colour for highlighting.
  8. Click OK, click OK

4) Cross Off Completed Items

If you have a list of the tasks that you have to work on, use conditional formatting to cross off completed items. In this example, completed tasks are marked with an X in the "Done" column.

There is a conditional formatting on the list, to cross off completed items, and change the font to light grey. That makes it easier to focus on the tasks that still need to be finished.

Conditional Formatting Strikethrough

To set up this conditional formatting, follow these steps:

  1. Select cells A2:C4
  2. On the Ribbon's Home tab, click Conditional Formatting, then click New Rule
  3. Click Use a Formula to Determine Which Cells to Format
  4. For the formula, enter   =$C2<>""
    • In each cell, the formula checks if column C in that row is empty
  5. Click the Format button, to open the Format Cells dialog box.
  6. On the Font tab, choose Strikethrough, and select light grey as the colour
  7. Conditional Formatting Strikethrough

  8. Click OK, click OK

After you set up the conditional formatting rule, the item will be crossed off, if you type anything in the "Done" column.

This example is on the Strikethrough sheet in sample file #1.

Shade Rows β¬’

The examples below show how you can use Excel conditional formatting to shade alternating rows on the worksheet, or groups of rows.

1 -- Shade Every Other Row

2 -- Shade Bands of Rows

3 -- Shade Bands by Group

4 -- Shade Alternating Filtered Rows

Shade Every Other Row

In the screen show below, the entire row is shaded green, for odd-numbered rows. This alternate shading can make it easier to read across a wide row of data.

shade alternating rows

  1. Click the Select All button, above the Row 1 button, to select all the cells on the worksheet.
  2. On the Ribbon's Home tab, click Conditional Formatting, then click New Rule
  3. Click Use a Formula to Determine Which Cells to Format
    • NOTE: In Excel 2003, choose Format|Conditional Formatting
    • Then, from the first dropdown, choose Formula Is
  4. For the formula, enter    =MOD(ROW(),2)
  5. Click the Format button.
  6. On the Patterns tab, select a colour for shading
  7. Click OK, click OK

Shade Bands of Rows

You can use Excel conditional formatting to shade bands of rows on the worksheet. In this example, 3 rows are shaded light grey, and 3 are left with no shading. In the MOD function, the total number of rows in the set of banded rows (6) is entered.

shade bands of rows

  1. Click the Select All button, above the Row 1 button, to select all the cells on the worksheet.
  2. On the Ribbon's Home tab, click Conditional Formatting, then click New Rule
  3. Click Use a Formula to Determine Which Cells to Format
    • NOTE: In Excel 2003, choose Format|Conditional Formatting
    • Then, from the first drop down, choose Formula Is
  4. For the formula, enter    =MOD(ROW(),6)<3
  5. Click the Format button.
  6. On the Patterns tab, select a colour for shading
  7. Click OK, click OK

Shade Bands by Group

You can use Excel conditional formatting to shade bands by group. In this example, the sales rows for the dates are in alternating colours - blue and no fill. This technique was adapted from Chip Pearson's site.

Tip: Another way to separate the groups is with a top border above the first date in each group.

dolour bands for dates

First, to prepare the table for shade bands by group, follow these steps:

  • In cell D1, type the heading for a new column - TRUE
  • In cell D2, enter this formula, which returns TRUE or FALSE.
    • =IF(A1=A2,D1,NOT(D1))

Next, follow these steps to add the conditional formatting:

  • Select all the data cells in the table
  • On the Home tab, click Conditional Formatting, New Rule
  • Click on "Use a formula to determine which cells to format"
  • In the formula box, type this formula, referring to the active data cell: =$D2=TRUE
  • Click the Format button, and choose a fill colour
  • Click OK, twice, to apply the formatting
  • (Optional) Hide the TRUE/FALSE column, to tidy up the worksheet.

Shade Alternating Filtered Rows

You can use Excel conditional formatting to shade alternating rows in a filtered list.

shade alternating rows in a filtered list

  1. Select the cells in the list (A2:B29 in this example).
  2. On the Ribbon's Home tab, click Conditional Formatting, then click New Rule
  3. Click Use a Formula to Determine Which Cells to Format
    • NOTE: In Excel 2003, choose Format|Conditional Formatting
    • Then, from the first drop-down, choose Formula Is
  4. For the formula, enter    =MOD(SUBTOTAL(3,$A$1:$A2),2)
  5. Click the Format button.
  6. On the Patterns tab, select a colour for shading
  7. Click OK, click OK
  8. Filter the list, and the shading will alternate in the visible rows.

Show Icons, Shapes or Colours

The following examples show how to create coloured shapes, or your own icon set, or show a specific colour in a cell.

1 -- Create Coloured Shapes

2 -- Create Coloured Icons

3 -- Show Selected Colour

1) Create Coloured Shapes ●

You can use Excel conditional formatting and the Wingding font to create coloured shapes in a cell. In this example, coloured shapes will appear in cells C3:C7, depending on the value in the adjacent cell in column B.

If the value is less than 10, a red circle will appear, if the value is greater than 30, a green square will appear. Otherwise, a yellow diamond will appear.

Create Coloured Shapes

  1. In cell C3 enter the formula:
        =IF(B3="","",IF(B3<10,"l",IF(B3>30,"n","t")))
  2. Copy the formula down to cell C7
  3. Format cells C3:C7 with Wingding font, and yellow font color
  4. Select cells C3:C7
  5. On the Ribbon's Home tab, click Conditional Formatting, then click New Rule
  6. Click Use a Formula to Determine Which Cells to Format
    • NOTE: In Excel 2003, choose Format|Conditional Formatting
    • Then, from the first drop-down, choose Formula Is
  7. For the formula, enter:   =$B3<10
  8. Click the Format button, and select Red as the font colour, then click OK.
  9. Click New Rule, and click Use a Formula to Determine Which Cells to Format
  10. For the formula,enter:  =$B3>30
  11. Click the Format button, and select Green as the font colour, then click OK.
  12. Click OK

2) Create Coloured Icons

In Excel 2007 and later, you can use icon sets to highlight the results in a group of cells. In Excel 2010 and later, you can customize these sets, but can't change the color of the icons.

  • If you don't have icons, or want to change the colors, you can use symbols, and a formula in an adjacent cell, to create your own icon sets.
  • Or, you can use custom Number Formats, as shown in the sample file, on the ColorIconsNum sheet.

Tip: Another option is to use Conditional Formatting Data Bars, that are like miniature charts in a range of cells.

Create Coloured Icons

First, set up the lookup table in cells G3:I5

  1. In G3:G5, type the percentages: 67%, 33%, 0%
  2. In H3, enter the formula: =PERCENTILE($D$2:$D$11,G3)
  3. Copy the formula down to rows 4 and 5
  4. Format cells H3:H5 in Wingding3 font
  5. Use Excel's Insert Symbols feature to add the up, right, and down arrows in those cells, from the Wingdings 3 font.
  • NOTE: You could use different percentages, or just type values into H3:H5

Next, create the icons in column C:

  1. In cell C2 enter the formula that creates the icon:
        =IF(D2="","",IF(D2>=$H$3,$I$3,IF(D2>=$H$4,$I$4,$I$5)))
  2. Copy the formula down to cell C11
  3. Format cells C2:C11 with Wingding3 font, and yellow font color
  4. Select cells C2:C11
  5. On the Ribbon's Home tab, click Conditional Formatting, then click New Rule
  6. Click Use a Formula to Determine Which Cells to Format
  7. For the formula, enter:   =$B2<$H$4
  8. Click the Format button, and select Green as the font colour, then click OK.
  9. Click New Rule, and click Use a Formula to Determine Which Cells to Format
  10. For the formula,enter:  =$B2>$H$3
  11. Click the Format button, and select Red as the font colour, then click OK.
  12. Click OK
  13. To make the icons appear to be in the same cell as the number, you can create an outside border around the two cells.

3) Show Selected Colour in Next Cell

Select a colour name from a drop down list, and the next cell fills with the selected colour.

  • There are no macros, just data validation drop downs and conditional formatting rules.

conditional format color

Watch this video to see the steps for creating this worksheet, and the written instructions are on the Show List and Colors page.

Rules Manager Tips βœ…

After you set up Conditional Formatting rules in Microsoft Excel, you might want to review the rules, or do some troubleshooting. To see the Conditional Formatting rules in the active worksheet, follow these steps:

  • On the Excel Ribbon, click the Home tab
  • Click the Conditional Formatting command
  • Click Manage Rules
  • At the top of the Conditional Formatting Rules Manager dialog box, select "This Worksheet" from the drop down list
    • conditional formatting manage rules

Each rule is listed, and shows its formula, format, range it applies to, and check box for "Stop if True".

conditional formattingrules

Quickly Check the Formulas

Only a small part of each formula is visible, and you can't show more. Unfortunately,

  • you cannot adjust the size of the Rules Manager window
  • you cannot adjust the column widths in the list of rules

However, you don't have to click the Edit Rule button, to see a full formula.

  • To see a full formula, point to one of the rules
  • Its full formula will appear in a pop up.

conditional formattingrules

After viewing the formula, if you need to edit it, click the Edit Rule button, and make your changes.

Extra Conditional Formatting Rules

When you check the Conditional Formatting Rules Manager, you might see a problem with new rules that have been created automatically. There might be a few rules duplicated, or you might see hundreds of extra rules!

You can see how to clean up those extra rules, with manual steps, or with a macro, on the Fix Conditional Formatting Extra Rules page.

duplicate conditional formatting rules

Download Sample Files ⬇️

1 -- Conditional Formatting Examples: Download the sample Excel Conditional Formatting file , with most of the examples from this page. The zipped Excel file is in xlsx format, and does not contain any macros.

2 --Hidden Data Warning: This sample file shows warnings, if rows or columns are hidden. Formula checks for hidden rows, and conditional formatting marks hidden column. Zipped file does not contain any macros.

3 -- Conditional Formatting for Weather Data: This sample file uses color scale for temperatures, and 4 formula rules for weather conditions - Sun, Cloud, Rain and Snow. The zipped file is in xlsx format, and does not contain macros

4 -- Hidden Questions: Main questions are visible, and conditional formatting hides the follow-up questions. The zipped file is in xlsx format, and does not contain macros

More Tutorials

Conditional Formatting Intro

Conditional Format Overview

Fix Conditional Formatting Extra Rules

Conditional Formatting Multiple Cells

Conditional Formatting - Currency

Conditional Formatting Documentation

Conditional Formatting Data Bars

Last updated: February 16, 2024 3:48 PM