EXCEL & GOOGLE SHEETS TIPS · LESSON 3
Conditional Formatting Based on Another Cell in Excel and Google Sheets
Color a whole row when one column says "Want", or turn an amount red when it is bigger than a limit you type in a separate cell. Both are conditional formatting rules with a custom formula. This lesson builds the two rules step by step in Excel and in Google Sheets, explains the dollar signs that make them work, and fixes the rules that color the wrong rows.
THE SHORT ANSWER
Use a custom formula that points at the other cell
=$E2="Want"Select A2:E11, add a rule with this formula, pick a fill color. Every row whose column E says "Want" turns yellow. The $ locks column E; the row number 2 has no $, so each row checks its own E cell.Select the range → Home → Conditional Formatting → New Rule → Use a formula to determine which cells to format → type the formula → Format… → pick a fill → OK.
Select the range → Format → Conditional formatting → Format cells if… → Custom formula is → type the same formula → choose a fill color → Done.
The example is the same expense log as lesson 1 (drop-down lists) and lesson 2 (VLOOKUP): the Type column is looked up from a Categories sheet, and now two rules color the log. Download the example file (Excel; it also opens in Google Sheets) to see both rules and change them.
HOW IT READS
Write the formula for the first row, lock the column
A conditional formatting formula must return TRUE or FALSE. You write it as if it were for the top-left cell of the range you selected, and the app copies it to every other cell the way a normal formula is copied down and across. That is why the dollar signs matter.
| You write | What each cell checks | Result |
|---|---|---|
=$E2="Want" | Every cell in row 5 checks E5, every cell in row 6 checks E6. | The whole row is colored. This is what you want. |
=E2="Want" | Column A checks E, column B checks F, column C checks G… | Only one column is colored, or nothing. |
=$E$2="Want" | Every cell checks E2 only. | All rows or no rows are colored, depending on row 2. |
=$E1="Want" with range from row 2 | Row 2 checks E1, row 3 checks E2… | The color lands one row too low. |
$I$1 below.EXCEL
Highlight the whole row based on another cell in Excel
- Select the rows to color, here A2:E11. Start at row 2, not at the header.
- Open the rule editor: Home → Conditional Formatting → New Rule. On a Mac you can also use the menu bar: Format → Conditional Formatting… and click +.
- Choose the formula type. On Windows pick Use a formula to determine which cells to format. On a Mac keep Style: Classic and pick the same option from the second list.
- Type the formula
=$E2="Want". Type it rather than clicking cells: a click inserts$E$2, which locks the row too. - Pick the format: click Format… (Windows) or Format with → Custom Format… (Mac), choose a fill color, then OK.
Press OK and every row whose Type is "Want" turns yellow. Change a category in column C (the Type updates by VLOOKUP) and the color follows by itself.
COMPARE WITH ANOTHER CELL
Turn amounts red when they are over a limit you type in a cell
Hard-coding a number (=$D2>150) works, but then every change means editing the rule. Put the limit in its own cell instead, here I1, and point the rule at it:
=$D2>$I$1Applied to D2:D11. Each amount is compared with the one value in I1. $I$1 is locked on both sides, so every row looks at the same cell.Now the limit is a setting anyone can change. Type 80 in I1 and the groceries and electric bill turn red as well:
To see, edit or reorder rules, open Home → Conditional Formatting → Manage Rules. Set "Show formatting rules for" to This Worksheet to list every rule on the sheet, not just those touching the selected cell.
GOOGLE SHEETS
Conditional formatting based on another cell in Google Sheets
- Select A2:E11 and open Format → Conditional formatting. A panel opens on the right with the range already in "Apply to range".
- Under "Format cells if…", open the list and choose the last option, Custom formula is.
- Type
=$E2="Want"in the box below it. The = sign is required. - Pick the style: the paint bucket sets the fill, the B and A buttons set bold and text color. Click Done.
- Add the second rule: select D2:D11, click Add another rule, choose Custom formula is and type
=$D2>$I$1.
=$D2>Settings!$B$1 directly. Google Sheets doesn't allow references to other sheets in conditional formatting; wrap the reference in INDIRECT instead: =$D2>INDIRECT("Settings!B1"). In Sheets, when two rules hit the same cell, the rule listed first wins; drag the rules in the panel to reorder them.COPY AND ADAPT
Ready-made formulas for common cases
Each works in both apps. Select the rows first (starting at row 2) and change the column letters to match your sheet.
| Goal | Custom formula |
|---|---|
| Row where a status cell says "Paid" | =$F2="Paid" |
| Row where a checkbox is ticked | =$G2=TRUE |
| Due date passed and not paid | =AND($B2<TODAY(), $F2<>"Paid") |
| Text contains a word (any case) | =ISNUMBER(SEARCH("ads", $B2)) |
| Either of two values | =OR($E2="Want", $E2="Savings") |
| Cell is empty (missing input) | =$D2="" |
| Actual over budget in the next column | =$C2>$B2 |
| Every other row (zebra stripes) | =ISEVEN(ROW()) |
Color scales and data bars color a cell by its own value, so use a formula rule whenever the condition lives in a different column. For the built-in "duplicate values" rule and its formula version, see lesson 7 (duplicates).
TROUBLESHOOTING
Conditional formatting based on another cell not working?
| What you see | Why | Fix |
|---|---|---|
| Only one column is colored | The column letter has no $: =E2="Want". | Use =$E2="Want". |
| The color is one row off | The formula is written for a different row than the first selected row (range starts at row 2, formula says row 1). | Make the row number match the first row of "Applies to" / "Apply to range". |
| Every row or no row is colored | The row is locked too: $E$2. Clicking a cell while typing the formula in Excel inserts this. | Delete the second $ so it reads $E2. |
| Nothing happens with a number limit | The limit or the amounts are text that looks like a number (a leading apostrophe, or imported from a CSV). | Retype the limit as a number; convert the column (Excel: warning icon → Convert to Number; Sheets: =VALUE() helper column). |
| "Invalid formula" in Google Sheets | The formula points to another tab, or uses typographic quotes copied from a document. | Use INDIRECT("Sheet!A1"); retype the quotes as straight quotes. |
| Text rule misses some rows | Extra spaces: "Want " is not "Want". Case does not matter. | Test with =TRIM($E2)="Want", or clean the column. A drop-down list prevents it. |
| New rows aren't colored | The rule's range ends at row 11. | Extend "Applies to" to $A$2:$E$500, or format the data as a table in Excel so the range grows. |
FAQ
Conditional formatting questions
How do I apply conditional formatting based on another cell?
Select the cells to format, create a new rule with a custom formula (Excel: "Use a formula to determine which cells to format"; Google Sheets: "Custom formula is") and reference the other cell, for example =$E2="Want". The formula is written for the first row of the selection.
How do I highlight an entire row based on one cell?
Select the whole table without the header, for example A2:E11, and use a formula with a dollar sign before the column letter only: =$E2="Want". Every cell in a row then checks the same column E value.
How do I compare a cell with a value in another cell?
Use a rule such as =$D2>$I$1, where I1 holds the limit. Lock both parts of the settings cell with $ so every row compares with the same cell.
Can conditional formatting reference another sheet?
In Excel 2010 and later, yes: =$D2>Settings!$B$1. In Google Sheets, wrap it in INDIRECT: =$D2>INDIRECT("Settings!B1").
Why is my conditional formatting formula not working?
Most often the $ signs are in the wrong place, the formula is written for a different row than the first selected row, or the compared values are text instead of numbers. Check the rule in Manage Rules (Excel) or the Conditional format rules panel (Google Sheets).
Does Excel's custom formula match text in any case?
Yes. ="Want" also matches "want" and "WANT". Use EXACT($E2,"Want") if case must match.