Every spreadsheet breaks sooner or later
If you maintain reports that other people built, or that you built a year ago and have half forgotten, you know the moment: a cell that should show a number shows #DIV/0!, and the total underneath it is broken too. Excel error values are not a sign that you are bad at spreadsheets. They are Excel’s way of telling you that a formula received something it cannot calculate with. The skill that separates a confident analyst from a nervous one is knowing what each error means, finding its cause quickly and choosing the right repair, one that fixes the problem without hiding the next one.
This free first lesson of the course deals with the most common error of all, #DIV/0!. You will work with Larkspur Office Supply, a fictional office-supplies distributor whose reports were built by several people over the years. Its product margin report shows two division errors: one for a product that has been discontinued and one for a product that is brand new. Both are perfectly normal business situations, and both deserve a different answer than a crash.
The lab above contains the real report. Read on for the background, a worked example with every number, step-by-step instructions, charts that show what goes on behind the scenes, and a list of the mistakes that make division errors come back.
What #DIV/0! actually means
Excel shows #DIV/0! when a formula divides by zero or by an empty cell. Mathematically, division by zero has no answer, so Excel refuses to invent one. An empty cell is treated as 0 in arithmetic, which is why a formula like =C6/B6 fails both when B6 contains 0 and when nobody has typed a value yet. Dividing by a cell that contains text, by contrast, gives #VALUE!, a different error that a later lesson covers.
The error does not stay where it starts. Any formula that uses the broken cell inherits the error: an AVERAGE over a range with one #DIV/0! returns #DIV/0!, a SUM returns it, and a chart either shows a gap or refuses to plot the series. That is why one zero in an input column can take down an entire dashboard.
In Larkspur’s report there are two divisions. The margin is gross profit divided by revenue: =C2/B2. The fax rolls were discontinued, so their revenue in B6 is 0 and the margin fails. The growth rate is this year’s revenue divided by last year’s, minus one: =B2/E2-1. The ergo chairs are new, so their last-year revenue in E8 is 0 and the growth rate fails. Same error code, two different stories, and the report should tell each story honestly.
Two ways to divide safely
There are two standard repairs, and the difference between them matters more than most tutorials admit.
1. Test the divisor with IF. =IF(B2=0,"n/a",C2/B2) checks the divisor before dividing. If revenue is 0 (or empty, since an empty cell equals 0 in a comparison), the cell shows the text "n/a"; otherwise it divides. The key advantage: only the division-by-zero case is caught. If someone later deletes a column or types text into B2, you still see #REF! or #VALUE!, which is exactly what you want.
2. Catch the error with IFERROR. =IFERROR(B2/E2-1,"New") calculates first and replaces any error with "New". It is shorter, it does not repeat the divisor, and it is the natural choice when the formula is long. The catch is in the word any: IFERROR also hides typos, missing lookup values, broken references and text where a number should be. Use it when you have thought about which errors can occur and you are happy for all of them to show the same fallback.
The second decision is the fallback value. It is tempting to write =IFERROR(C6/B6,0), because a zero looks tidy. But a 0% margin is a claim: it says the product was sold at cost. AVERAGE, MIN and MAX treat that 0 as a real result. Text such as "n/a" or "New" is different: AVERAGE, MIN, MAX, SUM and COUNT simply skip text in a range, so the fallback is excluded from your statistics instead of distorting them. An empty string "" behaves the same way in those functions, but it looks like a blank cell, which can confuse readers. For a report, a short visible word is usually the clearest choice.
Missing, zero or not applicable? Say what you mean
Before you pick a fallback, ask what the empty divisor really means in the business. For Larkspur there are three possible situations, and a good report distinguishes them. A product that is discontinued has a revenue of exactly 0, and a margin simply does not apply: "n/a" says that. A product that is new has no last-year figure, and its growth is not 0% and not infinite, it is "New". A value that has not arrived yet, such as a month whose figures are still being booked, is a different case again: a label such as "pending" or an empty-looking result warns the reader that the number will appear later.
Writing the label into the formula also documents the logic for the next person who opens the file. Someone who sees =IF(B2=0,"n/a",C2/B2) understands immediately that a zero revenue is expected and handled on purpose. A naked =C2/B2 next to a manually typed "n/a" in one row, by contrast, is a trap: the next time the data is refreshed, the typed text is overwritten or the formula is copied over it, and the error is back.
A shorter variant you will meet in other people’s files is =IF(B2,C2/B2,"n/a"). It works because Excel treats 0 and an empty cell as FALSE and every other number as TRUE. It is compact but less readable, so in shared reports the explicit B2=0 test is the friendlier choice.
Worked example: repairing Larkspur’s margin report
Here is the full report with the original formulas and the repaired results. Revenue, gross profit and last-year figures are the inputs from the lab; margin and growth are calculated.
| Product | Revenue | Gross profit | Last year | Margin =C/B | Margin repaired | Growth =B/E-1 | Growth repaired |
|---|---|---|---|---|---|---|---|
| Copy paper A4 | 48,200 | 9,640 | 45,100 | 20.0% | 20.0% | 6.9% | 6.9% |
| Ballpoint pens | 12,850 | 4,370 | 13,400 | 34.0% | 34.0% | -4.1% | -4.1% |
| Sticky notes | 9,420 | 3,580 | 8,760 | 38.0% | 38.0% | 7.5% | 7.5% |
| Toner cartridges | 36,700 | 8,070 | 39,950 | 22.0% | 22.0% | -8.1% | -8.1% |
| Fax rolls (discontinued) | 0 | 0 | 2,140 | #DIV/0! | n/a | -100.0% | -100.0% |
| Desk organisers | 7,980 | 2,950 | 7,220 | 37.0% | 37.0% | 10.5% | 10.5% |
| Ergo chairs (new) | 22,400 | 6,050 | 0 | 27.0% | 27.0% | #DIV/0! | New |
| Whiteboard markers | 5,310 | 2,020 | 5,480 | 38.0% | 38.0% | -3.1% | -3.1% |
| Total | 142,860 | 36,680 | 122,050 | 25.7% | 25.7% | 17.1% | 17.1% |
The repaired formulas are =IF(B2=0,"n/a",C2/B2) in D2, copied down to D9, and =IFERROR(B2/E2-1,"New") in F2, copied down to F9. The totals row did not need a repair because total revenue and total last-year revenue are not zero, so =C10/B10 and =B10/E10-1 work as they are.
Now the average margin. With "n/a" in D6, =AVERAGE(D2:D9) averages the seven active products and returns 30.9%. If D6 had been repaired with a 0 instead, the same formula would average eight values and return 27.0%, nearly four percentage points lower, purely because a discontinued product was counted as a product sold at cost. Nobody would notice by looking at the result, which is what makes this mistake dangerous.
| Cell | Question | Formula | Result |
|---|---|---|---|
| D6 | Margin of the fax rolls | =IF(B6=0,"n/a",C6/B6) | n/a |
| F8 | Growth of the ergo chairs | =IFERROR(B8/E8-1,"New") | New |
| B12 | Average margin, active products | =AVERAGE(D2:D9) | 30.9% |
| B13 | Divisor behind the #DIV/0! in D6 | cell address | B6 |
An auditing bonus: the total growth of 17.1% looks impressive, but it includes 22,400 of revenue from the new chairs and the 2,140 the fax rolls no longer bring. Comparing only the products that were sold in both years (revenue 120,460 against 119,910) gives a like-for-like growth of about 0.5%. The repair made the report correct; reading it critically makes it useful.
Step by step in Excel
- Find every error at once: press F5 (or Ctrl+G), click Special…, choose Formulas, untick everything except Errors and click OK. Excel selects all cells that currently show an error.
- Click an error cell, for example D6, and look at the formula bar:
=C6/B6. To see the inputs, use Formulas › Formula Auditing › Trace Precedents. Arrows point from B6 and C6 to D6. - For longer chains, use Formulas › Formula Auditing › Error Checking › Trace Error; Excel draws arrows back to the cell where the error first appeared. Remove Arrows in the same group clears them.
- Press Ctrl+[ to jump straight to the precedents of the active cell, which is handy when they sit on another sheet.
- In D2 type
=IF(B2=0,"n/a",C2/B2)and press Enter. Select D2:D9 and press Ctrl+D to fill the formula down. - In F2 type
=IFERROR(B2/E2-1,"New"), select F2:F9 and press Ctrl+D. - Align the text fallbacks with the numbers: select the columns, then Home › Alignment › Align Right, so "n/a" does not stand out as a misplaced label.
- In B12 type
=AVERAGE(D2:D9). Confirm it says 30.9% and not 27.0%. - Finally press Ctrl+` to switch to formula view and check that every row of D and F uses the same pattern.
=AGGREGATE(1,6,D2:D9) calculates an average that ignores error values (function 1 is AVERAGE, option 6 ignores errors). It is a good emergency fix for a summary cell, but repairing the errors where they start is still the better habit.
Common mistakes and how to spot them
- Using 0 as the fallback.
=IFERROR(C6/B6,0)turns “no data” into “zero margin” and pulls averages and minimums down. Spot it by checking whether a MIN of the column is suspiciously 0%. - Wrapping everything in IFERROR. A blanket IFERROR hides typos, broken references and failed lookups. If a report never shows an error, ask whether that is because it has none or because they are hidden. Test by temporarily typing text into an input cell and seeing whether anything reacts.
- Testing the wrong cell.
=IF(C2=0,"n/a",C2/B2)tests the numerator. The test must look at the divisor, the cell after the slash. - Fixing the symptom downstream. Wrapping the average in IFERROR leaves the broken cell in place and gives you a blank average. Fix the first cell in the chain, the one Trace Error points to.
- Forgetting the totals row. A total margin can also divide by zero, for example in a filtered view or an empty month. Repair it with the same pattern when its divisor can ever be 0.
- Turning off error checking. The small green triangles in the corner of cells are Excel’s own warnings. Leave the rules on under File › Options › Formulas › Error checking and read them instead of dismissing them.
Quick reference
| Function or tool | What it does | Example |
|---|---|---|
IF | Tests a condition before calculating | =IF(B2=0,"n/a",C2/B2) |
IFERROR | Replaces any error with a fallback | =IFERROR(B2/E2-1,"New") |
AVERAGE | Averages numbers, skips text | =AVERAGE(D2:D9) |
AGGREGATE | Average or sum that can ignore errors | =AGGREGATE(1,6,D2:D9) |
ERROR.TYPE | Returns the number of an error (2 = #DIV/0!) | =ERROR.TYPE(D6) |
| Trace Precedents / Trace Error | Draws arrows to the inputs of a formula | Formulas › Formula Auditing |
| F5 › Special › Errors | Selects all error cells | Find every #DIV/0! at once |
| Ctrl+[ | Jumps to the precedents of the active cell | From D6 to B6:C6 |
| Ctrl+D | Fills the top cell’s formula down the selection | D2 to D9 |
| Ctrl+` | Shows formulas instead of results | Audit a whole column |
Real-world uses
Division by something that can be zero is everywhere in business reporting. Typical places where the techniques of this lesson pay off:
- Monthly management reports: margin, cost per unit and conversion rate for a month in which a product, store or campaign had no sales yet.
- Year-over-year growth: new products, new customers or new branches have no prior-year value, so their growth should read “New” rather than an error or a fake 0%.
- KPI dashboards: ratios such as revenue per employee or tickets per agent for a team that is being set up and has no headcount in the data yet.
- Budget vs actual: variance percentages against budget lines of 0, where the absolute variance still matters but a percentage has no meaning.
- Survey and quality data: response rates and defect rates for groups with no responses or no inspected units.
What you will build in the rest of this course
Division errors are the easiest to understand. The remaining lessons take you through every other error Excel can show, always in Larkspur’s real-looking reports, and finish with a full audit routine.
#N/A from Lookups: Trailing Spaces, Numbers Stored as Text & IFNA. Three orders show #N/A, and each has a different cause: a stray trailing space, a product code that really is missing, and a customer ID stored as text. You learn to tell them apart and repair each the right way, using IFNA only where a missing value is genuinely expected.
#VALUE!: Text in Arithmetic, VALUE & SUBSTITUTE. A supplier export hides text inside numbers, so three lines and the total show #VALUE!. You find the culprits and convert them with VALUE and SUBSTITUTE until the purchase order adds up.
#REF! & Broken References: Deleted Cells, Relative vs Absolute after Copying. A commission sheet was copied without dollar signs and a column was deleted. You repair the references with absolute and mixed addressing and fix a #REF! total and a scenario grid.
#NAME? & #NUM!: Typos, Unquoted Text and Impossible Maths. A misspelled function, a text criterion without quotes and DATEDIF with its dates swapped. You learn to read #NAME? and #NUM! as precise hints rather than mysteries.
ISERROR, ISERR, ISNA & ERROR.TYPE: Classify and Count Errors. Before an import, you label every line of a supplier file with ISNA and ISERR, count the lines that would fail, decode error numbers and chart the result for the buyer.
Totals That Don't Add Up: Text Numbers, Double Counting & Check Sums. The hardest bugs show no error at all. You hunt down double-counted subtotals and numbers stored as text, measure what they leave out and reconcile the report with the ledger.
Model Audit Checklist: Check Cells & Red Flags. You finish with a reusable check panel: cross-foot differences, OK/CHECK flags with a tolerance, the repair of a stale hard-coded total and a red highlight that keeps open issues visible.
Summary
#DIV/0! means a formula divided by zero or by an empty cell, and the error spreads to every formula that uses it. Repair it where it starts. An IF test on the divisor catches only that case and lets every other error stay visible; IFERROR is shorter but hides everything. Choose a text fallback such as "n/a" or "New" so AVERAGE, MIN and MAX skip it, because a fallback of 0 is a fake result that distorts statistics: in Larkspur’s report it would lower the average margin from 30.9% to 27.0%.
Frequently asked questions
What does #DIV/0! mean in Excel?
It means a formula divided a number by zero or by an empty cell. Excel cannot calculate that, so it shows the error in the cell and in every formula that refers to it.
How do I remove #DIV/0! errors in Excel?
Test the divisor first with =IF(B2=0,"n/a",C2/B2), or catch the error with =IFERROR(C2/B2,"n/a"). The IF version only handles division by zero and lets other errors stay visible.
Should I use IF or IFERROR for division by zero?
Use IF when you want to catch only the zero divisor and still see other mistakes such as #REF! or #VALUE!. Use IFERROR when the formula is long and every possible error should show the same fallback.
Why does my average change when I replace errors with 0?
AVERAGE counts a 0 as a real value, so it pulls the average down. A text fallback like "n/a" or an empty string is skipped by AVERAGE, MIN and MAX, so the statistic only covers real results.
How can I average a range that contains #DIV/0!?
The best fix is to repair the error cells. As a quick workaround, =AGGREGATE(1,6,D2:D9) returns the average while ignoring error values.
How do I find all error cells in a worksheet?
Press F5, click Special, choose Formulas and tick only Errors. Excel selects every cell that shows an error, and Formulas › Error Checking › Trace Error shows where each one comes from.
Keep going: Excel Formula Errors & Auditing: #N/A, #VALUE!, #REF! and How to Fix Them
This free lab is lesson 1 of 20. Unlock the other 19 hands-on labs, the final exam and your certificate for a one-time $9.90.
- #N/A from Lookups: Trailing Spaces, Numbers Stored as Text & IFNA
- #VALUE!: Text in Arithmetic, VALUE & SUBSTITUTE
- #REF! & Broken References: Deleted Cells, Relative vs Absolute after Copying
- #NAME? & #NUM!: Typos, Unquoted Text and Impossible Maths
- ISERROR, ISERR, ISNA & ERROR.TYPE: Classify and Count Errors
- Totals That Don't Add Up: Text Numbers, Double Counting & Check Sums
- Model Audit Checklist: Check Cells & Red Flags
- SUBTOTAL & AGGREGATE: Totals Under Subtotal Rows and Maxima That Skip #DIV/0!
- Rounding Differences: Invoices Off by a Cent and the Penny Plug
- Circular References: Bonus on Profit After Bonus and Interest on the Average Balance
- Sign and Scale Errors: Credits Typed as Positives, Thousands Mixed with Units
- Hard-Coded Numbers in Formulas: ISFORMULA, FORMULATEXT and Hidden Plugs
- Range Errors: Totals That Miss New Rows and Misaligned SUMIF Ranges
- Error Cascades: Tracing an #N/A Back to Its Source in a Cash Roll-Forward
- Import Control Totals: Record Counts, Amount Totals and Hash Totals
- Period Mismatches: Annual, Monthly and Weekly Inputs in One Cost Model
- Error Impact and Materiality: From Reported to Corrected Profit with a Waterfall
- Audit Issue Log: Open Items by Severity, Days Open and Overdue Fixes
- Final Project: Model Health Dashboard for Larkspur's Budget