Excel Conditional Formatting Formula If Cell: Guide

Formulas & functions · Updated November 23, 2026

The core formula for conditional formatting in Excel is =IF(condition, TRUE, FALSE) used inside the rule, but you actually write just the condition itself (e.g., =A1>10) because Excel applies formatting only when the formula returns TRUE. For example, to highlight cells in A1:A10 that are greater than 10, select that range, go to Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format, enter =A1>10, set a format, and click OK.

How Conditional Formatting Formulas Work

Conditional formatting evaluates a formula for each cell in the selected range. The key is relative vs. absolute references. When you select a range like A1:A10 and enter =A1>10, Excel treats A1 as the “active cell” (the first cell in the selection). For each subsequent cell, the reference shifts: A2, A3, etc. This is why you usually write the formula relative to the top-left cell of the selection. If you want the formula to check a fixed cell, use absolute references like =$B$1.

For example, to highlight all rows in A1:D10 where the value in column B is greater than 100, select A1:D10, enter =$B1>100. The dollar sign before B locks the column, but the row number (1) is relative, so each row checks its own column B. This is a common pattern for row-based highlighting.

Writing the Formula: What to Put in the Rule Box

You do not type =IF() in the rule box. Instead, you type the logical test that would go inside an IF. For instance, to highlight cells that contain the word “Pending”, you could use =A1="Pending" (note the quotes). To highlight blank cells, use =ISBLANK(A1). To highlight duplicates, use =COUNTIF($A$1:$A$10,A1)>1. The formula must return TRUE or FALSE. If you accidentally type =IF(A1>10,"yes","no"), Excel will treat any non-zero text as an error and may not format as expected—stick to logical expressions.

Step-by-Step: Applying a Formula-Based Rule

  1. Select the range you want to format (e.g., A2:A20).
  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 condition, referencing the active cell (usually the first cell in the selection).
  5. Click Format… and choose a fill, font, or border.
  6. Click OK twice.

On Mac, the menu path is the same (Home tab > Conditional Formatting > New Rule). In Excel for the web, the rule editor is similar, but you must click “Custom formula is” in the dropdown.

Common Use Cases and Examples

  • Highlight overdue dates: Select due dates in C2:C20, enter =C2. This highlights dates before today.
  • Highlight top 10%: Use =C2>=PERCENTILE($C$2:$C$20,0.9) (note: PERCENTILE works, but Excel also has a built-in Top/Bottom Rules).
  • Highlight cells with errors: Select the range, enter =ISERROR(A1).
  • Highlight entire row based on a cell value: Select A2:D20, enter =$B2="Closed".
  • Highlight text that contains a specific word: Use =ISNUMBER(SEARCH("urgent",A1)).

Each example assumes the active cell is the top-left of the selection. Adjust references accordingly.

Why Use a Formula Instead of Built-In Rules?

Built-in rules (like “Greater Than” or “Text Contains”) are quick but limited. Formulas give you full control: you can combine conditions with AND/OR, reference other sheets, use functions like VLOOKUP or SUMIF, and apply logic that depends on multiple columns. For instance, to highlight a row only if both column A is “Yes” and column B is greater than 50, use =AND($A2="Yes",$B2>50). Built-in rules cannot do this without multiple rules or helper columns.

Formulas also let you use dynamic functions like TODAY(), ROW(), or MOD(ROW(),2)=0 to shade alternating rows. This is a classic use: select A1:D100, enter =MOD(ROW(),2)=0 to highlight even rows.

Common Problems and How to Fix Them

  • Formula works in a cell but not in conditional formatting: Check that the active cell reference is correct. If you select A2:A10 and enter =A1>10, it will check the cell above each selected cell—not what you want. Always reference the active cell (usually the first cell in the selection).
  • Absolute vs. relative references: Forgetting the dollar sign can cause the rule to check the wrong column. If you want to lock a column, use $B2; to lock a row, use B$2; to lock both, $B$2.
  • Text case sensitivity: =A1="yes" is case-insensitive in Excel. If you need case-sensitive, use =EXACT(A1,"yes").
  • Formula returns a number or text instead of TRUE/FALSE: Excel treats any non-zero number as TRUE, but it’s safer to use logical functions. For example, =A1>10 is fine; =IF(A1>10,1,0) also works because 1 is TRUE, but it’s less clear.
  • Rule not applying to new rows: Conditional formatting does not automatically expand when you insert rows. Either apply the rule to a larger range (e.g., A1:A1000) or use an Excel Table (Insert > Table) so formatting extends automatically.

Performance and Best Practices

Formulas that reference entire columns (like =A:A>10) can slow down your workbook because Excel evaluates them for every cell in the column. Instead, limit the range to the actual data area. Also, avoid volatile functions like INDIRECT or OFFSET in conditional formatting if possible, as they recalculate often. Use INDEX or direct references instead.

Another tip: if you have many rules on the same range, Excel applies them in order and stops at the first TRUE rule unless you check “Stop If True”. This can be useful for layered formatting, but it can also cause unexpected results—check the rule order in Manage Rules.

Frequently Asked Questions

How do I write an IF formula in conditional formatting?

You don’t write the full IF function. You write only the condition that would go inside the IF. For example, instead of =IF(A1>10,"yes","no"), you write =A1>10. Excel interprets TRUE as “apply format”. If you need multiple conditions, use AND or OR, like =AND(A1>10,B1<5).

Why is my conditional formatting formula not working?

The most common cause is a wrong active cell reference. When you select a range, the first cell you click is the active cell. Your formula must reference that cell (e.g., if you start at B2, use =B2>10). Also check that the formula returns TRUE for at least one cell—test it in a worksheet cell first. Finally, ensure you haven’t set “Stop If True” on an earlier rule.

Can I use a formula to highlight an entire row?

Yes. Select the entire row range (e.g., A2:D20), then use a formula that locks the column of the cell you’re checking. For example, =$B2="Completed" highlights rows where column B says “Completed”. The dollar sign before B keeps the column fixed, while the row number changes relative to each row.

How do I highlight cells based on another cell's value?

Use a formula that references that other cell. For example, to highlight A1:A10 when B1 is greater than 5, select A1:A10, enter =$B$1>5. The absolute reference $B$1 makes every cell check the same B1. If you want each row to check its own B column, use =$B1>5 (relative row).

Does conditional formatting work with dates and text?

Yes. For dates, use functions like TODAY() or EDATE(). For text, use EXACT for case-sensitive, or ISNUMBER(SEARCH()) for partial matches. Remember to use quotes around text strings in formulas, like =A1="Pending".

Can I use conditional formatting formulas in Google Sheets?

Yes, but the menu is different. In Google Sheets, go to Format > Conditional formatting, then under “Format cells if”, choose “Custom formula is”. The formula syntax is similar, but Google Sheets uses semicolons in some locales—check your spreadsheet settings. Also, Google Sheets does not support some Excel functions like PERCENTILE (use PERCENTILE works, but PERCENTRANK differs).

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.