sodcalculator

10 Tech How-To

Remove Div 0 Error in Google Sheets: 6 Fixes

Guide 10-35058 · Updated · Step by step

If you’re seeing a #DIV/0! error in Google Sheets, it means a formula is trying to divide by zero or by an empty cell. The fix is to either correct the divisor, use the IFERROR function to display a custom message, or use IF to check for zero before dividing. This article explains all the reliable methods, when to use each, and how to prevent the error from appearing in the first place.

What Causes the #DIV/0! Error?

Google Sheets displays #DIV/0! whenever a formula attempts to divide a number by zero (0) or by a cell that is empty. This is a standard error in spreadsheet applications, and it happens because division by zero is mathematically undefined. The error can appear in a variety of formulas, not just ones that use the forward slash (/) operator. For example, the AVERAGE function will return #DIV/0! if the range it’s averaging contains no numeric values. Similarly, functions like STDEV, VAR, and others that rely on a count of numbers will fail if that count is zero.

Common scenarios that trigger the error include:

  • Dividing by a cell that is currently blank because the user hasn’t entered data yet.
  • Dividing by a cell that contains a formula that returns 0 or an empty string.
  • Using AVERAGE on a range where all cells are empty or contain text.
  • Copying a formula down a column before the corresponding divisor cells are filled in.

Method 1: The IFERROR Function (Simplest Fix)

The quickest and most common way to remove the #DIV/0! error is to wrap your formula in the IFERROR function. This function checks the formula for any error, and if one is found, it returns a value you specify instead. This is ideal when you don’t care about the reason for the error and just want a clean result.

The syntax is: =IFERROR(your_formula, value_if_error)

For example, if your original formula is =A2/B2, you would change it to:

=IFERROR(A2/B2, "")

This will display an empty cell if B2 is 0 or blank. You can replace the empty string "" with any text, like "N/A" or "Not available", or use a number like 0. This is a great solution for dashboards and reports where you want to avoid ugly error messages.

Method 2: The IF Function (More Control)

If you need to handle the zero case differently from other errors, use the IF function. This gives you more control because you can check the divisor before performing the division. The syntax is:

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

This formula checks if B2 equals 0. If it does, it returns an empty string (or whatever you put in the second argument). If B2 is not 0, it performs the division. This method is slightly more efficient than IFERROR because it avoids calculating the division when it’s not needed, but the difference is negligible in most cases. It’s also useful when you want to treat a blank cell differently from a zero, although both will trigger the condition if you check for B2=0 since blank cells are treated as 0 in arithmetic.

Method 3: The IFERROR with ISERROR (For Specific Errors)

Sometimes you might want to hide only the #DIV/0! error but allow other errors like #N/A or #VALUE! to show. In that case, you can combine IF with ISERROR. The syntax is:

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

This will hide all errors, not just #DIV/0!. To specifically target #DIV/0!, you would need a more complex formula using IFERROR nested inside another IF, but in practice, most users are fine with hiding all errors. If you want to only hide #DIV/0! and show other errors, you can use:

=IF(ISERROR(A2/B2), IF(ERROR.TYPE(A2/B2)=2, "", A2/B2), A2/B2)

This is quite involved and rarely necessary. The simpler IFERROR method is usually sufficient.

Method 4: Use IF with ISBLANK (For Incomplete Data)

If the error is occurring because you haven’t entered data yet, you can use the ISBLANK function to check if the divisor cell is empty. This is a good practice for planning sheets where you want to leave the result blank until all inputs are provided. The syntax is:

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

This will return an empty cell if B2 is blank, but if B2 contains a 0, it will still return #DIV/0!. To handle both blank and zero, you can combine conditions:

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

This is a robust way to ensure the error only appears when the data is actually invalid (e.g., a negative number if that’s not allowed).

Method 5: Fix the Source Data (Prevention)

The best way to remove the #DIV/0! error is to prevent it from happening in the first place. This means ensuring that the cells used as divisors are never zero or empty. You can do this by:

  • Using data validation to restrict input to numbers greater than zero.
  • Using a formula to fill in a default value of 1 if the cell is empty.
  • Manually entering a placeholder value like 1 or a small number until the real data is available.

However, in dynamic spreadsheets where data is imported or entered by others, this is not always possible. In those cases, the IFERROR or IF methods are your best bet.

Method 6: Use ArrayFormula with IFERROR (For Multiple Rows)

If you are working with a large dataset and want to apply the fix to an entire column at once, you can use an array formula. Instead of dragging the formula down, you can write:

=ARRAYFORMULA(IFERROR(A2:A100/B2:B100, ""))

This will calculate the division for each row in the range A2:A100 and B2:B100, returning an empty cell for any row where the divisor is zero or blank. This is a huge time-saver and keeps your spreadsheet clean. Note that array formulas can be a bit tricky if you have other formulas in the same column, but for a simple division, it works perfectly.

Frequently Asked Questions

Why is my Google Sheets showing #DIV/0! when the cell is not zero?

If the divisor cell appears to have a value but the error persists, the cell might contain a formula that returns an empty string (“”). An empty string is not the same as a blank cell, but in arithmetic, it is treated as 0, causing the error. Check the divisor cell for any formulas that might return “” and adjust them to return 0 or a numeric value instead.

Can I hide the #DIV/0! error without changing the formula?

Yes, you can use conditional formatting to change the font color of the error to match the background, effectively hiding it. However, this is not recommended because it doesn’t fix the underlying issue and can confuse users who see a blank cell but the formula is still erroring. It’s better to use IFERROR or IF to handle the error properly.

What is the difference between IFERROR and IF in this context?

IFERROR catches any error (like #N/A, #VALUE!, #REF!) and replaces it with a value you specify. IF allows you to test a condition before performing the calculation, so you can specifically check if the divisor is zero and return a custom result. IFERROR is simpler, but IF gives you more control over the logic.

Will using IFERROR slow down my spreadsheet?

No, the performance impact is negligible for typical spreadsheet sizes. IFERROR is a lightweight function, and modern spreadsheet engines handle it efficiently. If you have a massive dataset with hundreds of thousands of rows, you might notice a slight slowdown, but it’s unlikely to be significant.

How do I get rid of #DIV/0! in a pivot table?

In a pivot table, the #DIV/0! error often appears when you have a calculated field that divides by a field that can be zero or empty. To fix it, you can edit the calculated field formula to use IFERROR, or you can filter out rows where the divisor is zero. Another option is to use the “Show values as” feature to change how the data is displayed, but this doesn’t always solve the division issue.

Is there a way to make all formulas ignore zero divisors automatically?

There is no global setting in Google Sheets to automatically ignore zero divisors. You must apply IFERROR or IF to each formula individually, or use an array formula to cover a range. Some add-ons might offer this feature, but they are not built into the standard software.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →