|
-
May 11th, 2004, 03:36 AM
#1
Thread Starter
Member
Replace Zeros with Blanks in This Code
The below code replaces all the #Div/0! Errors to Zeros. I want the code the generate Blanks instead of Zeros. Thanks you, Shan
Sub ErrorHandlerWrapper()
Dim sht As Worksheet
Dim rngCell As Range
Dim strOldFormula As String
Dim strNewFormula As String
Dim rngErrorCells As Range
For Each sht In ActiveWorkbook.Worksheets
On Error Resume Next
Set rngErrorCells = Nothing
Set rngErrorCells = sht.UsedRange.SpecialCells(xlCellTypeFormulas, xlErrors)
If Not rngErrorCells Is Nothing Then
On Error GoTo 0
For Each rngCell In sht.UsedRange.SpecialCells(xlCellTypeFormulas, xlErrors).Cells
strOldFormula = Right$(rngCell.Formula, Len(rngCell.Formula) - 1)
strNewFormula = "=IF(ISERROR(" & strOldFormula & "),0," & strOldFormula & ")"
rngCell.Formula = strNewFormula
Next rngCell
End If
Next sht
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|