Instant digital downloadExcel and Google SheetsSecure card checkout

Excel and Google Sheets how-to

Fix #DIV/0! in an average

An average of nothing is a division by zero, so AVERAGE shows #DIV/0! until the first number arrives. One IF fixes it.

ABC
1DayWeek 1Week 2
2Mon120
3Tue0
4Wed90
5Thu
6Fri
7Average70

Sample data. Daily sales; Week 2 has no numbers yet. The formula in B7 is copied to C7, which stays blank instead of showing #DIV/0!.

Why it happens

AVERAGE adds the numbers and divides by how many there are. With no numbers yet, that is a division by zero, so Week 2 shows #DIV/0!:

=AVERAGE(C2:C6)

Empty cells, and cells whose formula returns "" (empty text), are skipped, so a column of blanks has nothing to divide by. Week 1 works: (120 + 0 + 90) / 3 = 70.

The fix: check for numbers first

Count the numbers before averaging, and show a blank when there are none:

=IF(COUNT(B2:B6)=0,"",AVERAGE(B2:B6))

B7 still shows 70, and copied to C7 it shows an empty cell instead of the error. COUNT counts only cells that hold numbers, so empty cells and "" are not counted.

Show 0 instead of a blank

Swap the "" for a 0:

=IF(COUNT(C2:C6)=0,0,AVERAGE(C2:C6))

Week 2 now shows 0. A blank is usually clearer, because a 0 looks like a real result.

Why not just IFERROR?

This hides the error too:

=IFERROR(AVERAGE(C2:C6),"")

It works, but it hides every error, including a #N/A or #VALUE! from a broken cell inside the range, so a real problem goes unnoticed. The IF and COUNT version hides only the "no numbers yet" case and still shows #N/A when a cell in the range has one.

Leave the zeros out

If a 0 means "nothing recorded" rather than a real zero, average only the cells that are not 0:

=AVERAGEIF(B2:B6,"<>0")

Week 1 becomes (120 + 90) / 2 = 105. AVERAGEIF shows #DIV/0! when nothing is left to average, so on an empty week wrap it:

=IFERROR(AVERAGEIF(C2:C6,"<>0"),"")

Here IFERROR is the simple guard, since the only cells it can meet are your own numbers.

The same error in any division

Any formula that divides by an empty or zero cell shows #DIV/0!. With a total in D2 and a count in E2, check the count first:

=IF(E2=0,"",D2/E2)

With 50 in D2 and nothing or 0 in E2, the cell stays blank; with 4 in E2 it shows 12.5. An empty cell counts as 0 in this test. IF, COUNT, AVERAGE, AVERAGEIF and IFERROR work in every Excel since 2007 and in Google Sheets.

Templates with the math already done

Rather skip the formulas? These templates come with every formula built and checked, plus a filled-in sample.

More how-tos