How to Fix the #DIV/0! Error in Excel
#DIV/0! means something was divided by zero or by an empty cell. Wrap the division in IF so that when the divisor (B2) is zero or blank, it shows a blank instead of calculating.
Formula to use
=IF(B2=0, "", A2/B2)Blank when B2 is zero or empty
Show something other than a blank
To show 0 or "-" instead of a blank, change only the second argument of IF. Writing IF(B2, …) treats a zero or blank B2 as FALSE.
=IF(B2, A2/B2, 0)0 when B2 is zero or blank=IF(B2=0, "-", A2/B2)Show "-"
#DIV/0! from averages
AVERAGE with no numbers, or AVERAGEIF with no matching cells, ends up dividing by zero and gives #DIV/0!. Check the count first or wrap it in IFERROR.
=AVERAGEIF(A2:A9, "Jeju", D2:D9)#DIV/0! when there is no Jeju=IF(COUNTIF(A2:A9, "Jeju")=0, "None", AVERAGEIF(A2:A9, "Jeju", D2:D9))"None" when there is none
Careful with IFERROR
IFERROR hides every error, not just #DIV/0!. A #VALUE! caused by text in the divisor also turns blank, so mistakes can slip by. To catch only division by zero, IF is more precise.
=IFERROR(A2/B2, "")Turns every error blank
Try the functions used here
Change the arguments in the function playground and watch the calculation step by step.
- IF functionReturns one value if a condition is true and another value if it is false.
- IFERROR functionReturns a value you choose if a formula results in an error; otherwise returns the formula's result.
- AVERAGE functionReturns the average of the numbers. Text and blanks are left out, but 0 is included.
- AVERAGEIF functionAverages only the values in rows that meet a condition.
- COUNTIF functionCounts the cells in a range that meet a condition.
FAQ
- The divisor is not entered yet, so I get an error.
- A blank cell counts as 0. Use =IF(B2="", "", A2/B2) to show a blank until it is entered.
- Is it fine to show 0 instead of the error?
- 0 is handy when the value feeds a total, but a true ratio of 0 and "cannot calculate" then look the same, so choose to suit the use.