Conditional Format Formula: Excel Rules Explained

Formulas & functions · Updated November 23, 2026

The formula for conditional formatting in Excel is a rule you write that returns TRUE or FALSE; when it returns TRUE, the cell’s format is applied. For example, to highlight cells in A2:A10 that are greater than 100, select that range, go to Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format, enter =A2>100, and set a format.

How Conditional Formatting Formulas Work

Conditional formatting evaluates a formula for each cell in the selected range. The key is the relative reference: when you write =A2>100 for a range starting at A2, Excel applies the formula to every cell as if it were the active cell. The active cell (the first cell in the selection, usually the top-left) determines the reference point. For instance, if you select B2:B10 and enter =A2>100, it will highlight B2 if A2>100, B3 if A3>100, and so on. This lets you format one column based on another column’s values.

Choosing the Right Formula Type

Before writing a formula, decide what you want to highlight. The most common categories are:

  • Compare to a value: Use =A2>100, =A2<0, or =A2=50.
  • Text matching: Use =A2="Pending" (exact) or =ISNUMBER(SEARCH("urgent",A2)) for partial matches.
  • Dates: Highlight dates older than 30 days with =A2<TODAY()-30.
  • Blanks or errors: Use =ISBLANK(A2) or =ISERROR(A2).
  • Top/bottom values: Use =A2>=LARGE($A$2:$A$10,3) for top 3.

Always use absolute references ($) for ranges that should not shift, like the range in LARGE, and relative references for the cell being evaluated.

Common Formula Examples with Layout

Here are three worked examples. Assume a worksheet with headers in row 1 and data from row 2 down.

Example 1: Highlight overdue tasks (dates in B2:B20, status in C2:C20)

Select B2:B20, create a new rule with formula =AND(B2<TODAY(),C2<>"Done"). This returns TRUE for dates before today where status is not “Done”. The AND function checks both conditions.

Example 2: Highlight entire row when a checkbox is checked (checkbox in A2:A20)

Select A2:D20 (the data range), enter =$A2=TRUE. The dollar sign locks column A so the formula always looks at column A in the same row, but the row reference shifts. This highlights the whole row.

Example 3: Highlight duplicates in a list (names in A2:A100)

Select A2:A100, use =COUNTIF($A$2:$A$100,A2)>1. The formula counts occurrences of each cell’s value; if more than one, it highlights. The absolute range prevents the range from shifting.

Applying the Rule: Step-by-Step

  1. Select the range you want to format (e.g., A2:A10).
  2. Go to Home > Conditional Formatting > New Rule.
  3. Choose “Use a formula to determine which cells to format”.
  4. In the formula box, type your formula (no equals sign is needed, but it’s okay to include it).
  5. Click Format, choose a fill or font color, then OK.
  6. Review the rule in Conditional Formatting Rules Manager (Home > Conditional Formatting > Manage Rules) to edit or delete.

On Mac, the steps are the same; the ribbon is slightly different but the menu path is Home > Conditional Formatting > New Rule. In Excel for the web, the same options exist under Home > Conditional Formatting.

Troubleshooting Common Problems

If your rule doesn’t work, check these issues:

  • Wrong references: The formula must be relative to the active cell. If you selected A2:A10 and the active cell is A2, use =A2>100, not =A1>100.
  • Formula returns a number or text: Conditional formatting needs TRUE or FALSE. Wrap with =IF(...)? No—just use a comparison or a function like ISNUMBER that returns boolean.
  • Rule order: If multiple rules apply, the first rule in the manager wins unless “Stop If True” is checked. Reorder rules by moving them up/down.
  • Absolute vs relative: Forgetting $ can cause the range to shift incorrectly. For a fixed range, use $A$2:$A$10.
  • Text case: Text comparisons are case-insensitive in Excel, so =A2="pending" matches “Pending”.

Performance and Maintenance Tips

Conditional formatting formulas recalculate every time the sheet changes. For large datasets (thousands of rows), complex formulas can slow down Excel. To keep it fast:

  • Use simple functions like AND, OR, COUNTIF instead of array formulas.
  • Limit the range to the actual data, not entire columns (e.g., A2:A1000 instead of A:A).
  • Avoid volatile functions like TODAY() if the rule doesn’t need them; they recalculate on every change.
  • Use the Conditional Formatting Rules Manager to delete unused rules.

Frequently Asked Questions

Can I use a formula that references another sheet? Yes, you can reference another sheet, but the sheet name must be in single quotes if it contains spaces, e.g., =Sheet2!A2>100. The rule will work, but it may be slower if the other sheet is large.

Why does my formula work in a cell but not in conditional formatting? In a cell, you see the result; in conditional formatting, the formula must return TRUE or FALSE. Also, the reference must be relative to the active cell. If you copy the formula from a cell, it may have absolute references that break the relative logic.

How do I highlight a row based on a cell in another column? Use a mixed reference: lock the column with $ but let the row change, e.g., =$A2="Yes" applied to A2:D10. This checks column A in each row and highlights the entire row.

Can I use conditional formatting with formulas that return errors? Yes, but you need to handle errors. Use =IFERROR(A2,0)>100 to treat errors as 0, or =ISERROR(A2) to highlight errors themselves.

Is there a way to apply the same rule to multiple non-adjacent ranges? You can create one rule for a combined range by selecting multiple areas (hold Ctrl while selecting) and then applying the rule. The formula will use the first cell of the first area as the reference.

Does conditional formatting work in Google Sheets? Yes, but the interface differs. In Google Sheets, go to Format > Conditional formatting, select “Custom formula is” and enter the formula without the equals sign. The logic is the same, but the function names may differ (e.g., use ISBLANK in both).

Alternatives to Formula-Based Rules

If your condition is simple, built-in rules are easier: Home > Conditional Formatting > Highlight Cells Rules offers Greater Than, Text That Contains, A Date Occurring, and Duplicate Values. For color scales, data bars, and icon sets, use the pre-built options. Formulas are only necessary when you need to combine conditions, reference other cells, or create custom logic. For example, to highlight cells that are both greater than 50 and less than 100, you could use the Between rule, but to highlight based on a value in another column, a formula is the only way.

Remember to always test your formula on a few cells first by typing it in a helper column to see if it returns TRUE/FALSE correctly. This saves time and avoids frustration.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.