#div/0!

  • Thread starter Thread starter Tamesh
  • Start date Start date
T

Tamesh

With the data I have, there isn't always going to be a
value to divide by hence the #div/0! error. If I use the
if(iserror(),"",()) method, I'd have to re-input the
formula for every cell that does calculations. The data
is collected from a workbook that is multipaged with
named tabs thus making it a bit tedious to use the
formula in every cell (long tab names). Is there a way
to use a macro or something of that nature to fix this
issue on a large scale rather than one by one?
 
Tamesh,
if #div/0! error is in a cell with formulas use
Range("A1").Select
Selection.SpecialCells(xlCellTypeFormulas, 16).Select
Selection.ClearContents

if you have done copy and paste special values then
Range("A1").Select
Selection.SpecialCells(xlCellTypeConstants, 16).Select
Selection.ClearContents
HTH
Cecil
 
Cecil, exactly what does the code you just gave me do?
Thx for the help.
 
Have you tried Search & Replace for the text of the formula?
 
I tried that but I kept getting the message that my
search string could not be found (original value of cell)
 
Tamesh,
The code I gave you will clear the content of the cell if the formula in
that cell generates an error but I think you want to have the formula in
tact,
this code when run will change the formulas in the selection from
=The formula to
=if(iserror(The formula),"",The formula)

Sub Addiserror()
Dim cell As Range
For Each cell In Selection
If cell.HasFormula Then
cell.Formula = "=if(iserror(" & _
Replace(cell.Formula, "=", "", 1, 1, vbTextCompare) & _
"),""""," & _
Replace(cell.Formula, "=", "", 1, 1, vbTextCompare) & ")"
End If
Next cell
End Sub

HTH
Cecil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

handling #Div/0! errors 3
cell formula question 4
averages with formulas 5
Div 0 help 1
Help with VBScript/Access database 0
SUMPRODUCT excel ignore div/0 1
Change #DIV/0! across a range 3
Getting rid of #DIV/0! 2

Back
Top