maheshrk81
Board Regular
- Joined
- Jan 5, 2010
- Messages
- 153
Hi All,
I have a sheet with soo many formulas. but now i need to edit all the formulas with IFERROR, bcoz in few place i am getting #NA or #DVD. Now i need to change those values as 0(zero) with IFERROR formula.
I am using this below code but that is makin my cell empty.
Sub ErrorTrapAddDDL()
' Adds =If(IsError() around formulas
Dim cel As Range
Dim rng As Range
Dim Check As String
Const Equ As String = "=IF(ISERROR(_x) ,"""", _x)"
Check = Left$(Equ, 12) & "*" ' Check for =IF(ISERROR(
On Error Resume Next
Set rng = Selection.SpecialCells(xlFormulas, 23)
If rng Is Nothing Then Exit Sub
With WorksheetFunction
For Each cel In rng
If Not cel.Formula Like Check Then
cel.Formula = .Substitute(Equ, "_x", Mid$(cel.Formula, 2))
End If
Next
End With
End Sub
Kindly help me out..
Please....
Mahi
I have a sheet with soo many formulas. but now i need to edit all the formulas with IFERROR, bcoz in few place i am getting #NA or #DVD. Now i need to change those values as 0(zero) with IFERROR formula.
I am using this below code but that is makin my cell empty.
Sub ErrorTrapAddDDL()
' Adds =If(IsError() around formulas
Dim cel As Range
Dim rng As Range
Dim Check As String
Const Equ As String = "=IF(ISERROR(_x) ,"""", _x)"
Check = Left$(Equ, 12) & "*" ' Check for =IF(ISERROR(
On Error Resume Next
Set rng = Selection.SpecialCells(xlFormulas, 23)
If rng Is Nothing Then Exit Sub
With WorksheetFunction
For Each cel In rng
If Not cel.Formula Like Check Then
cel.Formula = .Substitute(Equ, "_x", Mid$(cel.Formula, 2))
End If
Next
End With
End Sub
Kindly help me out..
Please....
Mahi