Instant digital downloadExcel and Google SheetsSecure card checkout

Excel and Google Sheets how-to

Highlight a whole row with a conditional formatting formula

An order list where you want every late order to stand out, the whole row and not just the Status cell. One rule with a short formula does it, and it keeps working as statuses change.

ABCD
1OrderCustomerTotalStatus
21041Ana Silva120Paid
31042Ben Okafor85Late
41043Cara Liu240Paid
51044Dev Patel60Open
61045Eli Novak310Late
71046Fay Moreau95Paid
81047Gus Haddad150Open

Sample data: an order list in A1:D8. A conditional formatting rule on A2:D8 with the formula =$D2="Late" colours rows 3 and 6, the two late orders, from A to D.

The rule in Excel

Select the list from its first data row, A2:D8 here, so that A2 is the active cell. Then choose Home > Conditional Formatting > New Rule, click Use a formula to determine which cells to format, and type:

=$D2="Late"

Click Format, pick a colour on the Fill tab, then click OK twice. Rows 3 and 6, Ben and Eli, colour from A to D, and the other rows stay plain.

Microsoft's conditional formatting page says the formula has to start with an equal sign and "must return a logical value of TRUE (1) or FALSE (0)". Each cell in the range gets the colour when the formula is TRUE for it.

Why the $ goes before the D only

The formula is written for A2, the first cell you selected. For every other cell, the rule moves it the way a copied formula moves. The $ before D keeps every column looking at the Status column, and the 2 has no $, so each row looks at its own status. The two near misses:

  • =D2="Late" with no $: B2 looks at E2, C2 at F2 and D2 at G2, which are empty, so only column A colours on the late rows.
  • =$D$2="Late": every cell looks at D2, which says Paid, so nothing colours at all.

The trap behind both: Microsoft's page says "Selecting cells on the worksheet inserts absolute cell references." Click D2 while you write the rule and you get $D$2. Type the reference instead, or delete the $ before the 2.

Google Sheets: Custom formula is

Select A2:D8 and choose Format > Conditional formatting. In the panel on the right, open the Format cells if list and choose Custom formula is, the last choice. Type the same formula, =$D2="Late", pick a colour and click Done.

Google's conditional formatting help page colours a whole row the same way, with =$B1="Yes" for a list that starts in row 1. It also says a rule can only look at its own sheet: "To reference another sheet in the formula, use the INDIRECT function."

Test the formula in a cell first

A rule shows only colour, so a wrong formula is hard to spot. Type the rule's formula in an empty cell beside the list, at the same row as the top-left cell: =$D2="Late" in F2. Fill it right to I2 and then down to I8, the same size as A2:D8. Each cell shows TRUE where the rule will colour the matching cell and FALSE where it will not. Here rows 3 and 6 show TRUE in all four columns. Try =D2="Late" the same way and only the first column says TRUE. Delete the test cells when it looks right.

Past due, or older than 60 days

Say column E holds due dates. To colour the rows that are past due:

=AND(ISNUMBER($E2),$E2<TODAY())

A row due today stays plain and colours the next day. ISNUMBER keeps out the rows with no date yet: an empty cell counts as the oldest date of all, so =$E2<TODAY() on its own colours every row with a blank due date. To leave out the orders already paid:

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

For dates more than 60 days ago, take 60 off today:

=AND(ISNUMBER($E2),$E2<TODAY()-60)

A date exactly 60 days back stays plain; use <= instead of < to take it in. Use TODAY, not NOW, for dates without a time: a typed date is midnight, so =$E2<NOW() colours a row all through its due day. Both change only when the sheet recalculates; Microsoft's NOW page says it "is not updated continuously". If dates look stuck in Excel, check File > Options > Formulas and set Calculation options to Automatic.

Two conditions with AND or OR

To colour the late orders over 100 only:

=AND($D2="Late",$C2>100)

That colours Eli's row (310) and leaves Ben's (85). To colour a row that is late or over 200:

=OR($D2="Late",$C2>200)

That colours Ben, Cara and Eli. Microsoft's page gives =AND(B3="Grain",D3<500) as its own example of joining two checks. Over 100 means 100 itself stays plain; use >= to include it.

Percent cutoffs

A cell that shows 75% holds 0.75, and the rule compares that number. For scores in column C, either of these colours 75% and up:

=$C2>=75%

or =$C2>=0.75. Writing =$C2>=75 means 7500%, so it never colours anything. To change the cutoff without editing the rule, type it in a cell such as G1 and use:

=$C2>=$G$1

G1 gets both dollar signs because every cell in the list should read the same cutoff.

Cells with formulas, and errors

A cell can hold a formula and a rule at the same time, and the rule reads the result. We tested it in Google Sheets with =A1*2 in B1 and a rule for over 10: B1 coloured when A1 went from 4 to 7. In Excel, Microsoft's page warns that if a cell's formula returns an error, "conditional formatting is not applied to those cells", and suggests IFERROR or an IS function in the formula to give a value instead of the error.

Two rules on one list, edits and removing a rule

Excel: choose Home > Conditional Formatting > Manage Rules to see the rules; select one and click Edit Rule to change it. New rules go to the top of the list, and "A rule higher in the list has greater precedence than a rule lower in the list." Two rules that set different things, say bold and red, both apply; two that clash, say a red and a green fill, give the higher one. Move a rule with the Move Up and Move Down arrows, or tick Stop If True to stop at that rule. To remove rules, choose Conditional Formatting > Clear Rules, then Clear Rules from Selected Cells or Clear Rules from Entire Sheet.

Google Sheets: the help page says "Rules are evaluated in the order listed" and "The first rule found to be true will define the format of the cell or range." To reorder rules, click and drag them. To remove one, point to it and click Remove.

Free practice sheet

Three jobs to try: colour every late order, the whole row, with a test grid that shows what =D5="Late" and =$D$5="Late" get wrong; late orders over 100 and late or over 200 with AND and OR; and unpaid invoices past their due date, with due dates worked out from today so the tab never goes out of date. Each tab has yellow cells where you type the rule's formula first, a Check column that says Correct or Try again, and an Answers tab. One Excel file that opens in Google Sheets too; every tab works in any version of Excel. Free, no sign up. Sample data.

Download the practice sheet (.xlsx)

Templates with the math already done

Rather skip the formulas? These templates come with every formula built and checked, plus a filled-in sample.

Teaching this to a class or team?

Get one tip like this a month

A free email from VARS Digital with one Excel or Google Sheets fix, tested in both apps. No spam, unsubscribe any time.

By signing up you agree that VARS Digital, 10151 240 Street, Maple Ridge, BC V2W 0G9, Canada (inquiries@varsdigital.app) may email you its newsletter: Excel and Google Sheets tips, updates and news about our templates and lessons. We send a confirmation email first, and nothing else goes out until you click it. Every email has an unsubscribe link, and you can leave any time. Details in our store policies.

More how-tos