Last updated on November 10th, 2026 at 10:10 am
A formula in a cell can’t color that cell, but a conditional formatting rule built on a formula will. Select the cells, go to Home > Conditional Formatting > New Rule, choose Use a formula to determine which cells to format, and enter a formula that returns TRUE for cells to color, like =B2>C2. Select Format, pick a Fill color and select OK twice. These Windows steps follow Microsoft’s page on using conditional formatting to highlight information.
How a formula rule decides the color
A conditional formatting rule is a yes-or-no test that Excel runs on every cell you selected. You write the test once, for the first cell. If the result is TRUE, Excel applies the format you chose. If it’s FALSE, the cell keeps its normal look.
That’s why the formula has two jobs:
- It must start with an equal sign (=).
- It must give TRUE or FALSE (or 1 or 0). Comparisons like =B2>100, =C2=”Paid” or functions like ISBLANK and AND all do this.
An IF formula such as =IF(B2>100,”Red”,””) only returns text. It won’t color anything. Take the test inside the IF (B2>100) and use that as the rule instead.
Make a cell turn a color with a formula (Windows)
In this example, column B holds sales figures for B2:B50, and you want any value over 5,000 to turn green.
- Select the cells to color. Drag from B2 down to B50. Start at the top cell, because that cell becomes the one your formula is written for. Don’t include the header row.
- Open a new rule. On the Home tab, in the Styles group, select Conditional Formatting > New Rule. The New Formatting Rule dialog opens.
- Pick the formula rule type. Under Select a Rule Type, choose the last option, Use a formula to determine which cells to format. A box labeled Format values where this formula is true appears.
- Type the formula for the first cell. Enter =B2>5000. Write it as if you were only checking B2. Excel shifts the reference for B3, B4 and the rest on its own.

- Choose the color. Select Format, open the Fill tab and pick a color. You can also change the font color on the Font tab or add a border. Select OK.
- Check the preview and save. The Preview box shows your format. Select OK. Every sales figure over 5,000 turns green right away.
Change B7 from 4,800 to 5,200 and it turns green as soon as you press Enter. You don’t need to rerun anything.
Tip: if you click a cell while typing in the formula box, Excel inserts a locked reference such as =$B$2. Press F4 to cycle through the reference types until you get the one you want, or just type the reference.
Can an IF formula change a cell’s color?
No. IF can return a number, text or a TRUE/FALSE value, but never a fill color. Put the condition from your IF into a conditional formatting rule. If you need several outcomes, add one rule per outcome, or build the logic first with multiple IF statements in Excel and color the text results.
Can the color depend on a cell somewhere else on the sheet?
Yes, and that’s the main advantage of a formula rule over the built-in “greater than” options. Select the cells to color and refer to any other cell in the formula. =$E2=”Yes” colors column A when column E says Yes.
Steps on a Mac and in Excel for the web
Excel for Mac
- Select the cells, then choose Home > Conditional Formatting > New Rule.
- In the Style box, choose Classic.
- In the box below it, choose Use a formula to determine which cells to format.
- Type the formula for the first selected cell.
- In Format with, choose custom format, then set the color on the Fill tab and select OK until the dialogs close.
Microsoft’s Mac guide to formula-based conditional formatting walks through the same dialog with date, text and duplicate examples.
Excel for the web
Select the cells and choose Home > Conditional Formatting > New Rule. A Conditional Formatting pane opens on the right. Set the rule type to Formula, type your formula and choose a format. The pane’s labels differ slightly from the desktop dialog, but the formula itself is the same.
Dollar signs: which cells the formula checks
Most “wrong cells changed color” problems come from the dollar signs. A $ locks the column letter or the row number so it doesn’t move as Excel applies the rule to other cells.
| Reference | What stays fixed | Use it to |
|---|---|---|
| B2 | Nothing | Test each cell against itself |
| $B2 | The column | Color a whole row from one column |
| B$2 | The row | Color a whole column from one row, such as a header |
| $B$2 | Both | Point every cell at one target or limit cell |
If your colors form a diagonal staircase across a table, a column is missing its $. The same rules apply to ordinary formulas, which is why making an absolute reference in Excel is worth learning before you build bigger rules.
Formula examples you can copy
Each formula assumes the selection starts in row 2. Change the column letters to match your sheet.
| Turn a cell a color when… | Formula |
|---|---|
| It’s bigger than the cell next to it (actual vs budget) | =B2>C2 |
| It’s above a target typed in F1 | =B2>$F$1 |
| It’s the highest value in the column | =B2=MAX(B$2:B$100) |
| Either of two things is true | =OR(B2>5000,C2=”VIP”) |
| A date has passed | =AND(B2<>””,B2<TODAY()) |
| A date falls in the next 7 days | =AND(B2>=TODAY(),B2<=TODAY()+7) |
| It contains a word anywhere | =ISNUMBER(SEARCH(“urgent”,B2)) |
| It appears more than once | =COUNTIF($B$2:$B$100,B2)>1 |
| It’s blank but the cell beside it isn’t | =AND(A2<>””,B2=””) |
| It shows an error such as #N/A or #DIV/0! | =ISERROR(B2) |
| It’s a Saturday or Sunday | =WEEKDAY(B2,2)>5 |
| It’s on an even row (banding) | =MOD(ROW(),2)=0 |
| It doesn’t match the same cell on Sheet2 | =B2<>Sheet2!B2 |
For more on date rules, see how to make Excel cells change color automatically based on date. Text rules, including matching any word from a list, are covered in changing cell color based on text. To compare two lists side by side, use the methods for highlighting differences in two Excel columns.
Color an entire row based on one cell
Say column D holds a status, and you want the whole row red when it says “Late.”
- Select the full table without headers, for example A2:F100.
- Create a new formula rule and enter =$D2=”Late”.
- Pick a red fill and select OK twice.

The $ before D makes every cell in the row look at column D, so the full row changes together. Text in quotes isn’t case-sensitive here, so “late” and “LATE” also match. If you’d rather have those rows disappear than change color, you can hide rows based on a cell value with a filter or a short macro.
Use several colors in one range
One rule gives one color. For a traffic-light effect, add one rule per color to the same cells:
- Green: =B2>=90
- Yellow: =AND(B2>=70,B2<90)
- Red: =B2<70
Open Conditional Formatting > Manage Rules to see them. Rules run from top to bottom, and new rules are added at the top. When two rules set the same thing (two fill colors, for example), the higher rule wins. If they change different things, like a fill and a bold font, both apply. Use the arrow buttons to reorder rules, or tick Stop If True next to a rule so the rules below it are skipped for any cell where it’s TRUE. The full picture of rule types is in the guide on how to use conditional formatting in Excel.

Example: a monthly budget tracker
Jordan keeps a household budget with categories in column A, the monthly limit in column B and the amount spent in column C (rows 2 to 30). Two rules on C2:C30 make problems jump out:
- =C2>B2 with a red fill for categories that are over budget.
- =C2>=B2*0.9 with an orange fill for categories within 10% of their limit.
In Manage Rules, put the red rule on top and tick Stop If True for it. Now “Groceries” at $640 of a $600 limit shows only red, while “Fuel” at $185 of $200 shows orange. As Jordan enters receipts during the month, the colors update with no extra work.
Test, edit or remove a rule
Test the formula in a spare column first
Type the rule’s formula in an empty cell on row 2, such as H2, and fill it down. Excel shows TRUE or FALSE for each row. Every TRUE should match a cell you expect to change color. A FALSE where you expected TRUE usually points to a wrong reference or a missing dollar sign. Delete the helper column when you’re done.
Edit a rule
Select a colored cell and go to Conditional Formatting > Manage Rules. To see every rule on the sheet, set Show formatting rules for to This Worksheet. Select the rule, choose Edit Rule, and change the formula or format. The Applies to box controls which cells the rule covers, so you can widen it there instead of creating a second rule.
Remove the color
Press Ctrl + Z right after adding a rule to undo it. Later, choose Conditional Formatting > Clear Rules > Clear Rules from Selected Cells (or from Entire Sheet), or delete a single rule in Manage Rules. Any fill you added by hand comes back once the rule is gone.
Can I count or add up the colored cells?
Not by color with a built-in function. Since the color comes from a condition, count the condition instead: =COUNTIF(B2:B50,”>5000″) counts the same cells the first example colors. See how to use COUNTIF in Excel for more patterns.
Is the color kept when someone opens the file in another version?
Formula rules are saved in the .xlsx file and work in Excel for Windows, Mac and the web. Very old versions of Excel handle only a few rules per range, so keep rules simple if the file goes to someone on old software.
Start with one rule on a small range, check it with a helper column, then widen the Applies to range once it colors exactly the cells you expect.
Formula rules that don’t color the right cells
Nothing changes color
- The formula points at the wrong row. It must be written for the top-left cell of the selection. If you selected B2:B50, the formula should mention row 2, not row 1.
- Numbers are stored as text. Values pulled from other systems often look like numbers but compare as text. Look for a green triangle in the cell corner and convert them to numbers.
- Percentages don’t match. Excel stores 15% as 0.15, so compare with =B2>0.15, not =B2>15.
- The formula returns an error. Excel skips cells where the rule’s formula errors. Wrap the test in IFERROR, for example =IFERROR(C2/B2>0.2,FALSE).
- A higher rule is overriding yours. Check the order in Manage Rules.
The wrong cells change color
Open Manage Rules and look at both the formula and the Applies to range. A formula like =$B$2>C2 compares every cell with B2 only, while =B2>C2 moves with each row.
Arrow keys change the reference instead of moving the cursor
In the formula box, the arrow keys can pick cells instead of moving through your text. Press F2 to switch to editing, then use the arrows normally.
The rule won’t accept a link to another workbook
Conditional formatting can’t refer to a different workbook. Copy the values you need into a sheet in the same file and point the rule there. Other sheets in the same workbook work fine.
The color spreads when you copy cells
Copying and pasting cells carries their rules along. Paste values only to avoid that, or follow the guide to copy conditional formatting rules when you do want the same rule elsewhere.

Matt Jacobs writes and maintains the guides on Support Your Tech, which he started in 2017. He spent most of his career keeping small-business PCs running and still takes the occasional consulting job, so the steps here come from fixing the same problems on other people’s computers. Every guide is checked on his own Windows 11, Windows 10, Mac, iPhone and iPad before it goes up.