The #DIV/0! error in Excel: what it means and how to fix it
#DIV/0! means a formula divided by zero. Most often the cell it divides by is 0 or empty, because the number isn't in yet, and Excel counts an empty cell as 0. Fix the data if it's wrong, or show a blank or a dash instead with =IF(C2=0,"",B2/C2). It means the same in every version of Excel, on Windows and Mac and in Excel for the web.
Causes and fixes at a glance
| What you see | Why | Fix |
|---|---|---|
| #DIV/0! on some rows of a column | The cell you divide by holds 0 | =IF(C2=0,"-",B2/C2) |
| #DIV/0! on rows still being filled in | The cell you divide by is empty, which counts as 0 | The same IF, or type the missing number in |
| A total or average shows #DIV/0! | One of the cells it uses has the error | Fix that cell, and the total works again |
| AVERAGE or AVERAGEIF gives #DIV/0! | There are no numbers to average, or no rows match | =IFERROR(AVERAGEIF(…),"None yet") |
| A percentage change gives #DIV/0! | The old figure was 0 | =IF(B2=0,"New",(C2-B2)/B2) |
Each one is worked through below on a small sheet.
A worked example
A café works out its average spend per customer for each day: the takings divided by the number of customers.
- Monday: £318 from 53 customers. £318 ÷ 53 = £6.00.
- Tuesday: the café was shut, so 0 customers. £0 ÷ 0 can't be worked out.
- Wednesday: £402 from 67 customers. £402 ÷ 67 = £6.00.
- Thursday: nobody has typed the count in yet. An empty cell counts as 0, so that can't be worked out either.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Day | Takings | Customers | Per customer |
| 2 | Mon | £318.00 | 53 | £6.00 |
| 3 | Tue | £0.00 | 0 | #DIV/0! |
| 4 | Wed | £402.00 | 67 | £6.00 |
| 5 | Thu | £275.00 | #DIV/0! | |
| 6 | Average | #DIV/0! |
Excel is right: there's no answer to work out. But the error looks broken, and it spreads. The average in D6 uses D3 and D5, so it shows #DIV/0! too, and so would anything that used D6.
Show a blank or a dash: IF
Check the number you're dividing by first. If it's 0 (an empty cell counts as 0), show nothing; otherwise divide:
=IF(C2=0,"",B2/C2)
C2=0asks whether there are no customers. It's TRUE for 0 and for an empty cell.""is what to show if so: nothing. Put"-"instead to show a dash, which makes it clear the gap is on purpose.B2/C2is the usual answer for every other day.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Day | Takings | Customers | Per customer |
| 2 | Mon | £318.00 | 53 | £6.00 |
| 3 | Tue | £0.00 | 0 | - |
| 4 | Wed | £402.00 | 67 | £6.00 |
| 5 | Thu | £275.00 | - | |
| 6 | Average | £6.00 |
The average now works: AVERAGE and SUM skip the dashes, because they're text, so D6 is the average of Monday and Wednesday, £6.00. When Thursday's count is typed in, its row fills itself in.
If you'd rather show 0, put 0 in place of the dash. Think about who reads it, though: a 0 looks like customers who spent nothing, and it pulls the average down.
IF or IFERROR?
IFERROR also hides it: =IFERROR(B2/C2,"-"). The difference is what else it hides. Here someone has typed TBC in Wednesday's takings:
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Day | Takings | Customers | With IF | With IFERROR |
| 2 | Mon | £318.00 | 53 | £6.00 | £6.00 |
| 3 | Tue | £0.00 | 0 | - | - |
| 4 | Wed | TBC | 67 | #VALUE! | - |
- IF only catches the case you test for, a 0. The TBC still shows as #VALUE!, which is what you want: something needs fixing.
- IFERROR catches every error, including mistakes such as text in a number column, a misspelt function or a deleted column. Use it when any error has one meaning, such as "not found" after a lookup.
For dividing, IF is usually the better choice, because a 0 is the only error you expect. The #VALUE! error guide covers the TBC kind of problem.
An average of no rows
=AVERAGE(D2:D5) gives #DIV/0! if none of the cells hold a number: an average is a total divided by a count, and the count is 0. AVERAGEIF and AVERAGEIFS do the same when no rows match. Here the East team has no sales yet, so there's nothing to average:
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Team | Sale | Team | Average | Safe average | |
| 2 | North | £1,200.00 | North | £950.00 | £950.00 | |
| 3 | South | £800.00 | South | £900.00 | £900.00 | |
| 4 | North | £950.00 | East | #DIV/0! | None yet | |
| 5 | South | £1,000.00 | ||||
| 6 | North | £700.00 |
North has three sales, £1,200, £950 and £700, which add up to £2,850, and £2,850 ÷ 3 = £950. East has none, so its average would be £0 ÷ 0. The safe version counts the rows first:
=IF(COUNTIF($A$2:$A$6,D4)=0,"None yet",AVERAGEIF($A$2:$A$6,D4,$B$2:$B$6))
=IFERROR(AVERAGEIF($A$2:$A$6,D4,$B$2:$B$6),"None yet") is shorter and gives the same here. The COUNTIF way only catches "no rows", so a mistake elsewhere in the formula still shows.
Percentage change from zero
Change from last year is (this year − last year) ÷ last year. Pens went from £400 to £500, so the change is £100, and £100 ÷ £400 = 25%. Mugs are new this year, so last year was £0, and there's no percentage to give: dividing by 0 again.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Product | Last year | This year | Change | Safe change |
| 2 | Pens | £400.00 | £500.00 | 25% | 25% |
| 3 | Mugs | £0.00 | £120.00 | #DIV/0! | New |
| 4 | Bags | £250.00 | £200.00 | -20% | -20% |
A word such as New says more than a blank here. There's more on working out changes in percentages in Excel.
Other places it turns up
Dividing by a formula's answer
If the number you divide by comes from another formula, click that cell and check what it really holds. A 0 gives #DIV/0!. A formula that shows "" looks empty too, but dividing by it gives #VALUE! instead, because "" is text.
MOD with 0
=MOD(A2,0), the remainder after dividing by 0, gives #DIV/0! for the same reason.
Finding every error on a sheet
Press Ctrl+G (on a Mac, Control+G) to open Go To, click Special, choose Formulas and tick only Errors. Excel selects every cell showing an error, so you can see where they are before you decide how to fix them. To follow one back to the cell it starts from, click it and use Trace Precedents: see formula auditing.
Try it now
In D2, work out the spend per customer: the takings divided by the customers. Where there are no customers (0 or blank), show a dash, "-", instead of #DIV/0!. Your formula will be copied down to D8.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Day | Takings | Customers | Per customer |
| 2 | Mon | £318.00 | 53 | |
| 3 | Tue | £0.00 | 0 | |
| 4 | Wed | £402.00 | 67 | |
| 5 | Thu | £275.00 | ||
| 6 | Fri | £96.00 | 0 | |
| 7 | Sat | £0.00 | 12 | |
| 8 | Sun | £615.00 | 82 |
Open this in Try a formula: the same sheet with the answer filled in, to change or share by link.
Part of Excel data analysis practice: every lesson on the topic, with a project in Excel.
Where it works
#DIV/0! and the IF fix work the same in every version of Excel, on Windows and Mac, and in Excel for the web. IFERROR needs Excel 2007 or later.
Questions
What does #DIV/0! mean in Excel?
It means a formula tried to divide by zero, which has no answer. Usually the cell it divides by holds 0, or is empty, because Excel counts an empty cell as 0. AVERAGE gives it too when there are no numbers to average. The formula is often fine: the number it needs just isn't there yet. Check the cell you divide by, then fill it in or catch the 0 with IF.
How do I show a blank instead of #DIV/0!?
Check the cell you divide by before dividing: =IF(C2=0,"",B2/C2). When C2 is 0 or empty, the cell shows nothing; otherwise you get the usual answer. Put "-" in place of "" for a dash, or 0 for a zero. =IFERROR(B2/C2,"") also works, but it hides every other error too, such as text typed into a number column.
Why does AVERAGE give #DIV/0!?
An average is the total divided by how many numbers there are. If the range has no numbers in it, only blanks or text, that count is 0, so AVERAGE divides by 0. AVERAGEIF and AVERAGEIFS do the same when no rows match. Count first, then average: =IF(COUNT(B2:B9)=0,"",AVERAGE(B2:B9)), or use COUNTIF with the same condition for AVERAGEIF.
Should I use IF or IFERROR to fix #DIV/0!?
For dividing, IF is usually better: =IF(C2=0,"-",B2/C2) catches only the 0 you expect, so other mistakes such as a word typed in place of a number still show as an error. IFERROR hides every error with the same message. Use IFERROR when any error means the same thing, or when the formula is already checked and you just want a tidy sheet.