Convert #DIV/0!

mickeystanford_alumni

Board Regular
Joined
May 11, 2022
Messages
129
Office Version
  1. 2021
Platform
  1. Windows
  2. MacOS
Hi again everyone,
Is there any way to convert all #DIV/0! into blank cells?
I have a big file and every sheet has some #DIV/0!.
I don't want to go one by one putting the =IFERROR(,0) then:

Is there any way to get rid of them? Also it would work if in all #DIV/0! I insert the =iferror formula, however, in an automated way? Guess that's not possible right?

Txs for any ideas.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
The best thing to do would be to address/update all division formulas so this won't happen.
This happens when you try to divide by 0.
So, if you have a formula like this:
Excel Formula:
=A1/B1
if you rewrite it like this, it won't return that #DIV/0 error:
Excel Formula:
=IF(B1=0,"",A1/B1)

Note that if you are trying to use this value in further calculations, and provide a blank is problematic because it won't allow you to do mathematical functions on it, you may need to return a 0 instead of a blank like this:
Excel Formula:
=IF(B1=0,0,A1/B1)
 
Upvote 0
You could do it with code. What do you want as the last argument of the IFERROR?
 
Upvote 0
for the IFERROR I would just need =IFERROR(formula already in place which is giving me the DIV error), 0)
Just note that the IFERROR function handles ALL errors, which may or may not be a good thing (depending on your need).
For example, if you accidentally typed in a text value, and tried to divide that by a number, you will get a #VALUE error.
The IFERROR function will hide that error too. So you wouldn't be alerted of that typo error, as the IFERROR function will hide it.
 
Upvote 0
Just note that the IFERROR function handles ALL errors, which may or may not be a good thing (depending on your need).
For example, if you accidentally typed in a text value, and tried to divide that by a number, you will get a #VALUE error.
The IFERROR function will hide that error too. So you wouldn't be alerted of that typo error, as the IFERROR function will hide it.
that's okay as I don't have any other errors and I will not have. Its just the annoying thing to see the DIV errors in the same cells...
 
Upvote 0
This will add an IFERROR handler to all formula error cells. It could be amended to only handle specific errors if you prefer:

VBA Code:
Sub FixFormulaErrors()
   Application.ScreenUpdating = False
   Dim ws As Worksheet
   For Each ws In ActiveWorkbook.Worksheets
      Dim errorCells As Range
      On Error Resume Next
      Set errorCells = Nothing
      Set errorCells = ws.UsedRange.SpecialCells(xlCellTypeFormulas, xlErrors)
      On Error GoTo 0
      If Not errorCells Is Nothing Then
         Dim cell As Range
         For Each cell In errorCells.Cells
            cell.Formula = "=IFERROR(" & Mid$(cell.Formula, 2) & ",0)"
         Next cell
      End If
   Next ws
   Application.ScreenUpdating = True
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,940
Messages
6,122,352
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top