Excel Conditional Formatting with Formulas: 10 Practical Examples

Excel conditional formatting with formulas examples

Conditional formatting makes problems jump out of a sheet: overdue invoices in red, top performers in green, duplicates highlighted. The built-in rules (Greater Than, Top 10, Data Bars) cover simple cases. When you need anything more specific, such as colouring a whole row or comparing with another column, you use a formula rule.

This guide shows how formula rules work and gives 10 ready-to-use examples.

How to add a formula rule

  1. Select the range to format, starting from the top-left cell, for example A2:F100.
  2. Home → Conditional Formatting → New Rule.
  3. Choose Use a formula to determine which cells to format.
  4. Type a formula that returns TRUE or FALSE for the first cell of the selection (A2 here).
  5. Click Format, pick a fill colour, and press OK.

Excel copies the formula to every other cell in the selection, exactly like copying a normal formula. That is why the dollar signs matter.

The dollar-sign rule

  • $E2: column locked, row free. Every cell in a row looks at column E of that row. Use this to colour whole rows.
  • E2: nothing locked. Each cell looks at itself. Use this to colour single cells.
  • $H$1: fully locked. Every cell looks at the same cell, for example a target value.

Most "my rule colours the wrong cells" problems come from a missing or extra dollar sign.

Sample data

Columns: A Invoice, B Customer, C Region, D Due date, E Amount, F Status. Data in rows 2 to 100.

10 formula examples

1. Highlight the whole row when status is "Overdue"

Select A2:F100:

=$F2="Overdue"

2. Highlight rows where amount is above a target in H1

=$E2>$H$1

Change H1 and the formatting updates at once.

3. Highlight due dates that have passed

Select D2:D100:

=AND(D2<>"", D2<TODAY(), $F2<>"Paid")

The D2<>"" part stops blank cells being coloured, because Excel treats a blank as 0, which is an old date.

4. Due in the next 7 days

=AND(D2>=TODAY(), D2<=TODAY()+7)

5. Two conditions on the row (AND)

=AND($C2="North", $E2>=50000)

6. Either condition (OR)

=OR($F2="Overdue", $F2="Disputed")

7. Highlight duplicates in one column

Select A2:A100:

=COUNTIF($A$2:$A$100, A2)>1

To highlight only the second and later copies, use an expanding range: =COUNTIF($A$2:A2, A2)>1.

8. Values that are not in another list

If valid customer names are in Customers!A:A:

=COUNTIF(Customers!$A:$A, $B2)=0

Rows with an unknown customer turn red, which is a quick data-quality check before a lookup.

9. Zebra stripes (every other row)

=MOD(ROW(), 2)=0

Stripes stay correct even after sorting or filtering the data, unlike manually coloured rows.

10. Top 3 amounts per region

=$E2>=LARGE(IF($C$2:$C$100=$C2, $E$2:$E$100), 3)

Works directly in Excel 365. In older versions, a simpler alternative is =COUNTIFS($C$2:$C$100, $C2, $E$2:$E$100, ">"&$E2)<3, which counts how many larger amounts exist in the same region.

Manage and order rules

Home → Conditional Formatting → Manage Rules shows every rule, the range it applies to, and its order. Rules higher in the list win when two rules set the same format. Tick Stop If True to prevent lower rules from running when a higher one matches.

Common problems

  • Nothing gets formatted: the formula is written for the wrong first cell. If you selected from row 2, the formula must refer to row 2.
  • Only one column colours: you used E2 instead of $E2 for a whole-row rule.
  • Every row is coloured: you used $E$2, so every row checks the same cell.
  • Text versus numbers: =$E2>50000 does nothing if amounts are stored as text. Convert them first.
  • Slow workbook: rules on entire columns with complex formulas slow Excel down. Apply them to the used range or an Excel Table.

Tip: use an Excel Table

Convert the data to a Table (Ctrl + T) and apply the rule to the Table's data area. New rows added to the Table pick up the rule automatically.

Practice task

In an invoice list, create three rules: overdue and unpaid rows in light red, invoices due within 7 days in yellow, and paid invoices in grey text. Put them in the right order in Manage Rules so a paid invoice is never shown as overdue.

Related: IF with AND and OR, SUMIFS and COUNTIFS, and conditional formatting in Power BI: colors, icons and data bars with DAX.

Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Learn Excel, Power BI, and Finance in Simple Hindi and English Follow step-by-step tutorials and practical examples designed for students, job seekers, and working professionals. We cover Power BI dashboards, DAX formulas, Excel tricks, financial literacy, and AI tools.