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.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Order | Customer | Total | Status |
| 2 | 1041 | Ana Silva | 120 | Paid |
| 3 | 1042 | Ben Okafor | 85 | Late |
| 4 | 1043 | Cara Liu | 240 | Paid |
| 5 | 1044 | Dev Patel | 60 | Open |
| 6 | 1045 | Eli Novak | 310 | Late |
| 7 | 1046 | Fay Moreau | 95 | Paid |
| 8 | 1047 | Gus Haddad | 150 | Open |
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$1G1 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.
- Invoice Template and TrackerInvoices with a payment tracker for paid and overdue.
- Bill TrackerEvery bill, due date and payment for the year, with overdue flags.
- Task Tracker SpreadsheetOne row per task with the owner, priority, status and due date.
Teaching this to a class or team?
More how-tos
- Find a price by its code with XLOOKUPType a product code, get its price back from your price list. One formula, no helper columns.
- Total each category with SUMIFSAdd up all the Fuel, all the Office, all the Meals: one formula per category, and more rules when you need them.
- Check two conditions at once with IF and ANDFree shipping only when the order is 50 or more and ships in Canada: one IF, one AND, done.
- Add leading zeros to numbersType 00021 and Excel or Google Sheets shows 21, because to them it is just the number 21. Here is how to get the zeros back, and keep them.
- Fix #DIV/0! in an averageAn average of nothing is a division by zero, so AVERAGE shows #DIV/0! until the first number arrives. One IF fixes it.
- Count rows that meet two conditions with COUNTIFSHow many of Ana's deals were 500 or more? COUNTIFS answers it in one cell, and takes as many rules as you need.
- Calculate percentage changeSales went from 400 to 500. That is a 25% increase, and one short formula works it out for every row.
- Calculate years of service from a start dateAna started on 15 March 2019. How many full years has she worked? DATEDIF counts them, and the same formula works out an age from a date of birth.
- Combine first and last name into one cellFirst names in one column, last names in the next, and you need "Ana Lopez" in one cell. The & sign joins them.
- Find duplicates in a list with COUNTIFA mailing list where some people signed up twice. One formula shows how many times each email appears, so the repeats stand out.
- Split a full name into first and last nameYour list has "Ana Lopez" in one cell and you need Ana and Lopez in two. Two short formulas find the space and split there.
- Total amounts by month with SUMIFSA list of dated expenses and you want one total per month. SUMIFS adds every amount between the first and the last day of the month.
- Count working days between two datesAna is off from 1 Oct to 14 Oct. How many working days is that? NETWORKDAYS counts Monday to Friday and leaves out the weekends.
- Hide #N/A in VLOOKUP with IFERRORYour order list has a code that is not in the price list, and VLOOKUP shows #N/A. IFERROR puts your own words there instead.
- Count cells that contain textA stock list where some items have a note and most do not. One COUNTIF with an asterisk counts the notes and skips the empty cells.
- Make a running total (cumulative sum)Monthly sales in one column, the total so far in the next. One formula, filled down.
- Round to 2 decimal places, up or downA 15% discount turns 12.99 into 11.0415. ROUND makes it 11.04 and keeps your totals right to the cent. ROUNDUP and ROUNDDOWN handle the times when nearest is the wrong answer.
- How long to $1,000,000? FV and NPERPut $500 a month away at an example 7% a year. FV says what it grows to, NPER says when it passes $1,000,000. Two formulas, no calculator site.
- Why your formula gives the wrong number: the order of operationsA2 holds 10 and A3 holds 4. What does =A2-A3*2 give? It is 2, not 12. The same rule explains most formulas that look right and give the wrong number.
- Why your SUM says 0, and how to fix itThe amounts are right there in the column, and the total says 0. They look like numbers, but the sheet has them stored as text, and SUM skips text.
- Fill handle not working? Copy a formula down fastYou wrote one formula and need it in every row. Here are the quick ways to copy it down, and what to check when the fill handle will not show up or the copies come out wrong.
- Calculate hours worked from start and end timesA shift from 9:00 to 17:30 is 8.5 hours, but subtract the times and the cell shows 8:30. One small change turns it into a number you can add up and multiply by a pay rate.
- IF a cell is blank, or not blankYou want a formula to do one thing when a cell is empty and something else when it is filled. Two double quotes do the job, and they also catch the blanks ISBLANK misses.
- Formulas not updating? Recalculate and refreshYou change a number and the total does not move. It is nearly always one of a handful of things, and each one takes seconds to fix once you know which.
- Standard deviation in Excel and Google SheetsTwo shops both average 40 orders a day. One sells 38 to 42 every day; the other swings from 25 to 55. The average cannot tell them apart. The standard deviation can.
- Stack several columns into one column with TOCOLNames in three columns, one for each day, and you need them in one list. One formula does it, and the list keeps up when the columns change.
- Long numbers turn into E+ or end in 0 in ExcelYou type a 12 digit order number and Excel shows 5.93774E+11. You type a 16 digit account number and the last digit turns into 0. The first one is only how the cell looks. The second is a real loss, and it has to be stopped before you type.
- Count how many times each value appears in a columnA staff list with a department on every row, and you need to know how many people are in each department. Two short formulas build the count table, and it keeps up when the list changes.
- Freeze rows and columns so the headers stay on screenMonths across the top, names down the side, and once you scroll a little both slide away and you lose track of whose row you are reading. Freezing keeps them on screen while the rest of the sheet moves.
- Free pricing calculatorsPrice a job from your real costs and margin. No sign up.
- Free downloadsPractice sheets and printable pages, no email and no sign up.







