How to Fix the #DIV/0! Error

#DIV/0! means a formula tried to divide by zero or by an empty cell. It is common in percentage, average and growth formulas where some rows have no data yet. Describe your calculation below and get a formula that shows a blank or zero instead.

Free, no sign-up required · 5 free generations a day

Last updated

Describe your task, get the formula

Type what you need in plain English, or pick an example below. You get the formula, a step-by-step explanation, and a worked example.

Formulas that prevent #DIV/0!

Syntax
=IF(B2=0,"",A2/B2)
=IFERROR(A2/B2,0)
=IFERROR(AVERAGEIF(A2:A100,"East",B2:B100),"")

Testing the divisor with IF is the precise fix: the division only runs when B2 is not zero, and a blank cell counts as zero. IFERROR is shorter but hides every other error as well. AVERAGE and AVERAGEIF also return #DIV/0! when there is nothing to average.

Examples

Show a blank when the divisor is zero

=IF(B2=0,"",A2/B2)

Checks the divisor first. If B2 is zero or empty the cell stays blank, otherwise the division runs as normal.

Percentage change without the error

=IF(B2=0,0,(C2-B2)/B2)

Returns the growth from B2 to C2 as a fraction, and 0 when there is no starting value to compare against. Format the cell as a percentage.

Conditional average with no matching rows

=IFERROR(AVERAGEIF(A2:A100,E2,B2:B100),"-")

AVERAGEIF returns #DIV/0! when no row matches the condition. IFERROR replaces that with a dash.

Common mistakes and how to fix them

Replacing the error with 0 distorts later averages

A zero is a real number and is included in AVERAGE. Return an empty string instead, which AVERAGE ignores, when no result should count.

IFERROR hides a broken formula

IFERROR also swallows #REF!, #NAME? and #VALUE!. Use the IF test on the divisor when you only want to handle division by zero.

The error shows in a pivot table or chart

Fix the source formula rather than the pivot. In a pivot table you can also open PivotTable Options and set a value to show for error cells.

Frequently asked questions

What does #DIV/0! mean?

It means division by zero. The divisor in the formula is 0 or an empty cell, and dividing by zero has no defined result.

Why does AVERAGE return #DIV/0!?

AVERAGE divides the total by the count of numbers. If the range has no numbers at all — only blanks or text — the count is zero and the division fails.

Is the fix the same in Google Sheets?

Yes. IF, IFERROR and AVERAGEIF work identically. Google Sheets shows the same #DIV/0! text for the error.

Don't want to write it by hand?

Describe what you need in plain English and get a ready-to-use formula in seconds.

Try the formula generator