DIV/0 ERROR - How eliminate them in many cells contemporaneously
Try this, it only appends the if(iserror to cells with div/0! errors:
Sub test()
Dim cell As Range
Dim div0formula As String
For Each cell In ActiveSheet.UsedRange
If IsError(cell.Value) Then
If cell.Value = CVErr(xlErrDiv0) Then
div0formula = Mid(cell.Formula, 2)
cell.Formula = "=IF(ISERROR(" & div0formula & "),"""","
& div0formula & ")"
End If
End If
Next cell
End Sub
Metallo wrote:
Hi,
Thanks Pascal.
However, if anybody as got another solution, it's very welcom.
Thank you
Alex
"Papou" wrote in message ...
Hi
Try something like this (there surely is something better) :
Sub AddErrorTrap()
Dim UsdRng, Cel As Range, OldFormula$, NewFormulaPart1$, NewFormula$
NewFormulaPart1 = "=IF(ISERROR("
Set UsdRng = ActiveSheet.UsedRange
For Each Cel In UsdRng
If Cel.HasFormula Then
OldFormula = Right(Cel.Formula, Len(Cel.Formula) - 1)
NewFormula = NewFormulaPart1 & OldFormula & "),""""," & OldFormula & ")"
Cel.Formula = NewFormula
End If
Next Cel
End Sub
HTH
Regards
Pascal
"Metallo" a écrit dans le message de news:
. ..
Hi,
Normally, I use the formula (EXAMPLE):
=IF(ISERROR(G12/G11*1000),"",G12/G11*1000)
In this way I prevent the error to appear.
The problem is that somebody sent me a very big Excel file with plenty
of DIV Errors, therefore I am asking how I can apply my formula to all
of them in one go.
Certainly, I cannot do this cell by cell and I am sure there is a
"batch" process I can use.
Thanks for your help
Alex
|