A #DIV/0! error appears whenever Excel tries to divide a number by zero or by an empty cell. It is one of the most common errors in dashboards and KPI sheets, because ratios such as conversion rate, average order value or growth percentage all depend on a divisor that is sometimes missing. This guide shows how to fix DIV/0 error results in Excel with IF, IFERROR, AVERAGEIF and COUNT checks, and how the same fixes work in Google Sheets and LibreOffice Calc.
Every example uses one small store report, and a free practice workbook with the same data is attached to this post.
What the #DIV/0! error means
Excel returns #DIV/0! when the divisor in a formula is 0 or blank. That includes a typed formula such as =5/0, a reference to an empty cell, and functions that divide internally, such as AVERAGE, AVERAGEIF and AVERAGEIFS when there is nothing to average. ERROR.TYPE returns 2 for this error, which is handy when you need to tell it apart from other errors.
Unlike #REF!, the formula itself is not damaged. It is usually waiting for data that has not arrived yet, so the goal is to decide what the cell should show until it does.
The sample data
The report sits in A5:E10. Lake View has no visitor count yet, and MG Market recorded no orders this week.
| Store | Region | Visitors | Orders | Revenue |
|---|---|---|---|---|
| Kochi Road | South | 1250 | 85 | 6120 |
| MG Market | South | 980 | 0 | 0 |
| Lake View | North | 40 | 2900 | |
| Station Plaza | West | 1430 | 112 | 8400 |
| Hill Top | North | 760 | 51 | 3570 |
A simple revenue-per-order formula in F6, =E6/D6, returns 72 for Kochi Road but #DIV/0! for MG Market. A conversion formula, =D8/C8, fails for Lake View because the visitor cell is blank.
How to fix DIV/0 error results with IF
The cleanest fix checks the divisor before dividing. Excel treats 0 and a blank cell as FALSE inside IF, so the divisor itself can be the test:
=IF(D6,E6/D6,"")
Copied down F6:F10, this returns 72, an empty cell, 72.5, 75 and 70. Microsoft’s article on how to correct a #DIV/0! error recommends exactly this pattern. Show a message instead of a blank when readers need to know why a value is missing:
=IF(C6,D6/C6,"No data")
For the conversion rate in G6:G10 this gives 6.8%, 0%, No data, 7.8% and 6.7%. Note that MG Market correctly shows 0%: zero orders divided by 980 visitors is a real result, not an error.
If you prefer an explicit test, =IF(D6=0,””,E6/D6) does the same job, because an empty cell also equals 0 in a comparison.
Use IFERROR for a quick catch-all
IFERROR returns its second argument when the first one produces any error:
=IFERROR(E7/D7,0)
For MG Market this returns 0 instead of #DIV/0!. It is short and works in every modern version of Excel, but it hides every error type, including #VALUE! from text in a number column or #NAME? from a typo. Use it when the formula is already tested, and prefer the IF check when you only want to handle zero divisors. Our guide to fixing the #VALUE! error explains why masking the wrong error causes trouble later.
AVERAGE, AVERAGEIF and empty ranges
Averages divide a total by a count, so they return #DIV/0! when nothing qualifies. With the region to check in H7, this formula fails for East because no store is in that region:
=AVERAGEIF(B6:B10,H7,E6:E10)
Wrap it so the result explains itself:
=IFERROR(AVERAGEIF(B6:B10,H7,E6:E10),"No stores")
For East it shows No stores, and with North in H8 it returns 3235, the average of 2900 and 3570. For a plain AVERAGE over a range that might be empty, test the count first: =IF(COUNT(E6:E10)=0,”No entries”,AVERAGE(E6:E10)).
Ratios of totals
Summary rows often divide one SUM by another. Check the bottom total before dividing:
=IF(SUM(D6:D10)=0,"",SUM(E6:E10)/SUM(D6:D10))
This returns about 72.88, the overall revenue per order (20990 divided by 288). It is also more accurate than averaging the per-store results, because large and small stores are weighted correctly. In Excel 365 you can name the divisor once with LET: =LET(o,SUM(D6:D10),IF(o=0,””,SUM(E6:E10)/o)).
Quick reference: causes and fixes
| Situation | Formula that fails | Fix |
|---|---|---|
| Divisor is 0 | =E7/D7 | =IF(D7,E7/D7,””) |
| Divisor cell is blank | =D8/C8 | =IF(C8,D8/C8,”No data”) |
| Any error is acceptable to hide | =E7/D7 | =IFERROR(E7/D7,0) |
| No rows match AVERAGEIF | =AVERAGEIF(B6:B10,”East”,E6:E10) | Wrap in IFERROR with a message |
| AVERAGE of an empty range | =AVERAGE(J6:J10) | =IF(COUNT(J6:J10)=0,”No entries”,AVERAGE(J6:J10)) |
| Total row with zero total | =SUM(E6:E10)/SUM(D6:D10) | Test SUM(D6:D10)=0 first |
Find and count #DIV/0! errors
- Go To Special: press F5 (or Ctrl+G), choose Special, then Formulas and tick only Errors to select every error cell on the sheet.
- Count them: =COUNTIF(K6:K10,”#DIV/0!”) counts only divide-by-zero results, so you can confirm the number drops to zero after each fix.
- Trace the divisor: select the cell and use Formulas > Error Checking > Trace Error to highlight the blank or zero precedent.
- PivotTables: in PivotTable Options, on the Layout & Format tab, tick For error values show and leave the box empty or type a dash.
Microsoft also suggests typing #N/A into a divisor cell that is not available yet. The formula then shows #N/A, which charts skip instead of plotting as zero.
#DIV/0! in Google Sheets and LibreOffice Calc
Google Sheets uses the same error name. Hover over the cell to read the reason, for example that parameter 2 of the DIVIDE operation cannot be zero, or that evaluating AVERAGE caused a divide by zero error. The IF, IFERROR, AVERAGEIF and COUNT fixes above work unchanged, and Sheets also offers =IFERROR(DIVIDE(E7,D7),0) if you prefer the function form of division.
LibreOffice Calc shows #DIV/0! for error code 532, division by zero. The LibreOffice Calc error codes page lists it with the others, and the same IF test works there. If a lookup feeds the divisor, also read how to fix the #N/A error, since a missing match can surface as either error.
Practice workbook
The companion workbook has the store report, two input cells for regions and a column of mixed results. Fill the yellow cells with the IF, IFERROR, AVERAGEIF and total-ratio formulas, count the #DIV/0! results, then compare your answers with the Solutions sheet.
FAQ
Should I return 0 or a blank instead of #DIV/0!?
Use a blank or a short message when the value is unknown, and 0 only when zero is the true answer. A 0 drags averages and charts down, while a blank is ignored by AVERAGE and most charts.
Why does =IF(D6,E6/D6,””) work without a comparison?
IF treats 0 and an empty cell as FALSE and any other number as TRUE, so the division only runs when the divisor is a non-zero number.
Does IFERROR slow down large workbooks?
Not noticeably for normal sheets. The bigger risk is that it hides other errors, so add it only after the formula returns correct results.
Download the practice workbook
The same data as this tutorial, with empty answer cells and a Solutions sheet.