Spreadsheet error

How to fix the #DIV/0! error

TL;DR

#DIV/0! means the formula divided by zero or by an empty cell. Fix: wrap in IFERROR, or guard with IF(denominator=0, 0, numerator/denominator).

What it means

The #DIV/0! error appears when a division operation has zero (or an empty cell, which Excel treats as zero) as the denominator. AVERAGE on an empty range also triggers this.

Common causes

How to fix it

1.Wrap in IFERROR

  1. Change =A2/B2 to =IFERROR(A2/B2, 0)
  2. Or return empty string: =IFERROR(A2/B2, "")
  3. Or a message: =IFERROR(A2/B2, "N/A")

2.Guard with IF

  1. =IF(B2=0, 0, A2/B2)
  2. More explicit than IFERROR because it only handles the zero case and not other unrelated errors.

3.For AVERAGE, check the range

  1. If AVERAGEIF returns #DIV/0!, the criteria matched no cells.
  2. Wrap: =IFERROR(AVERAGEIF(A:A, "x", B:B), 0)
  3. Or pre-check count: =IF(COUNTIF(A:A, "x")=0, 0, AVERAGEIF(A:A, "x", B:B)).

Example

Broken=A2/B2Fixed=IFERROR(A2/B2, 0)

If B2 is empty or zero, the division fails with #DIV/0!. IFERROR returns 0 instead.

Prevention

Related errors

#NUM!#VALUE!#N/A

Let FormulaPad debug it for you

Paste your broken formula and the error message — get a diff and an explanation in seconds.

Debug a formula