Learn Excel
EN
Sets how numbers, dates and formulas look, so everything works just like your own Excel.

Home › Excel basics › Conditional formatting

Conditional Formatting in Excel: Rules, Formulas and Examples

Conditional formatting changes how a cell looks based on its value: red for overdue, green for on target, a bar for size. The formatting updates automatically when the data changes, so problems stand out without anyone looking for them.

In this guide
  1. Quick rules
  2. Data bars, scales, icons
  3. Top 10 and above average
  4. Highlight whole rows
  5. Format a cell based on another cell
  6. Highlight dates: overdue, today and next week
  7. Blank cells and missing input
  8. Several rules on one range
  9. Tips
  10. Manage and remove rules
  11. Copy conditional formatting to other cells
  12. Keep learning
  13. FAQ

Quick rules: highlight cells

  1. Select the range, for example the sales figures in C2:C100.
  2. Go to Home › Conditional Formatting › Highlight Cells Rules.
  3. Choose a rule, such as Greater Than…, type 1000, pick a format and click OK.

Other useful built-in rules in the same menu:

  • Less Than / Between / Equal To for thresholds.
  • Text that Contains, for example every cell with "urgent".
  • A Date Occurring: yesterday, this week, last month.
  • Duplicate Values: highlights every value that appears more than once.
  • Top/Bottom Rules: the top 10 items, the bottom 10%, or above average.

Try it yourself: select B2:B7, choose Home › Conditional Formatting › Highlight Cells Rules › Less Than, type 20 and click OK. Turn on JavaScript to practise this in an interactive Excel window.

Data bars, color scales and icon sets

These show the size of a value instead of a yes/no condition.

  • Data Bars: a bar inside each cell, longer for larger values. Great for a quick in-table chart.
  • Color Scales: a gradient, for example red for low and green for high. Turns a table into a heat map.
  • Icon Sets: arrows, traffic lights or ratings based on thresholds.

Top/bottom rules: top 10 and above average

Want the best or worst values to stand out, without choosing a fixed number yourself? Select the range and go to Home › Conditional Formatting › Top/Bottom Rules:

  • Top 10 Items / Bottom 10 Items: change 10 to any number, for example the top 3 sales.
  • Top 10% / Bottom 10%: a share of the list instead of a fixed count.
  • Above Average / Below Average: Excel calculates the average itself and updates it when the numbers change.

The same with a formula, if you want to color the whole row: =$C2>AVERAGE($C$2:$C$100) for above average, or =$C2>=LARGE($C$2:$C$100,3) for the top 3 (see LARGE and SMALL).

Highlight an entire row with a formula

Built-in rules only format the cell they test. To color the whole row when a value is high, use a formula rule.

ABC
1RegionRepSales
2NorthAnna1,200
3SouthBen800
4NorthChris950
5EastDana450
  1. Select the whole table without headers: A2:C5.
  2. Home › Conditional Formatting › New Rule › Use a formula to determine which cells to format.
  3. Enter: =$C2>1000
  4. Click Format, choose a fill color, and click OK twice.

The $ before C locks the column, so every cell in the row checks column C; the row number 2 has no $, so each row checks its own value. Only Anna's row is colored. More on this in absolute references.

More formula ideas:

  • Overdue tasks: =AND($D2<TODAY(), $E2<>"Done")
  • Zebra stripes: =MOD(ROW(), 2)=0
  • Highlight a row when a status is "Cancelled": =$B2="Cancelled"

Tip: test the formula in a cell first. A rule formula must return TRUE or FALSE. Type it in an empty cell next to the first row, for example =$C2>1000, and fill it down. Where you see TRUE, the rule will color the cell. Once it's right, copy the formula into the rule and delete the test column.

Format a cell based on another cell

Choose Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format. Example: colour the amounts in B2:B20 red once the due date in column C has passed. Select B2:B20 and enter =$C2<TODAY(). The $ before C keeps the rule looking at column C; the 2 without $ lets it move down row by row.

Compare with a fixed cell instead: =B2>$E$1 colours every amount above the target in E1. Change E1 and the colours follow.

Highlight dates: overdue, today and next week

For quick date rules choose Highlight Cells Rules > A Date Occurring and pick Yesterday, Today, Last 7 days or Next week. For your own limits, use a formula rule on the dates in column A:

  • =A2<TODAY(): overdue
  • =AND(A2>=TODAY(), A2<=TODAY()+7): due in the next 7 days
  • =WEEKDAY(A2, 2)>5: Saturdays and Sundays

Highlight blank cells and missing input

An empty cell in a list is easy to miss. To make every empty cell stand out: select the range, choose Home › Conditional Formatting › New Rule › Format only cells that contain, pick Blanks in the first box, choose a fill and click OK. Formula version: =B2="".

Often only some empty cells are a problem. Say every order in column A needs an invoice number in column D. Select D2:D100 and use =AND($A2<>"",$D2=""): the cell turns yellow only when the row has an order but no invoice number yet. Fill it in and the color disappears, so the sheet shows you what still needs doing.

Several rules on the same cells

A traffic light needs three rules on the same range, for example sales in C2:C100: green from 1000, orange from 500, red below 500. Add them one by one, then open Manage Rules:

  • Rules are checked from top to bottom. When two rules set the same thing (for example the fill color), the rule higher in the list wins.
  • Put the strictest rule at the top: =$C2>=1000 above =$C2>=500. The other way round, 1200 would turn orange.
  • Tick Stop If True to skip the rules below once a rule applies.
  • Rules that change different things combine: a red fill from one rule and bold text from another both show.

Tips for clear conditional formatting

  • Convert the range to a table first (Excel tables). New rows you add at the bottom get the rules automatically.
  • Use colors consistently: green for good, red for a problem, and no more than two or three colors per sheet. If everything is colored, nothing stands out.
  • Don't rely on color alone: around 1 in 12 men is color-blind. An icon set or a bold font helps there.
  • Keep the rules tidy: copying and pasting cells creates duplicate rules. Check Manage Rules now and then and delete what you don't need.

Manage, edit and remove rules

  • Home › Conditional Formatting › Manage Rules shows every rule for the selection or the whole sheet. Change the order, the range ("Applies to"), or tick "Stop If True".
  • Clear Rules in the same menu removes rules from the selected cells or the entire sheet.
  • Copying cells also copies their rules. Too many overlapping rules can slow a workbook down, so clean them up regularly.

Copy conditional formatting to other cells

Click a cell that has the rule, click Format Painter (the brush on the Home tab) and drag over the new cells. The rule now covers those cells too. To check or adjust the range, open Conditional Formatting > Manage Rules and look at Applies to.

Frequently asked questions

Why isn't my conditional formatting formula working?

Usually the dollar signs are wrong, or the formula is written for a different starting row than the selected range. Write the formula for the first row of the selection.

Can I use conditional formatting based on another cell?

Yes, with a formula rule. For example, select B2:B100 and use =$C2="Late" to color column B based on column C.

How do I highlight duplicates?

Select the range and choose Home › Conditional Formatting › Highlight Cells Rules › Duplicate Values.

How do I copy conditional formatting to other cells?

Use the Format Painter, or Paste Special › Formats. Or edit the "Applies to" range in Manage Rules.

Can I apply more than one rule to the same cells?

Yes. Excel checks the rules from top to bottom in Manage Rules; when two rules set the same format, the higher one wins. Put the strictest rule at the top.

Does conditional formatting update automatically?

Yes, the colors change as soon as the values change. For new rows, convert the range to a table so the rules grow with the data.

Can I copy conditional formatting to another sheet?

Yes. Select the cells with the rule, click Format Painter, switch to the other sheet and drag over the target cells.