Thread: macro - replace
View Single Post
  #2  
Old March 26th, 2010, 03:39 AM posted to microsoft.public.excel.newusers
Gord Dibben
external usenet poster
 
Posts: 20,252
Default macro - replace

Sub ErrorTrapAdd()
Dim mystr As String
Dim cel As Range
For Each cel In Selection
If cel.HasFormula = True Then
If Not cel.Formula Like "=IF(ISERROR*" Then
mystr = Right(cel.Formula, Len(cel.Formula) - 1)
cel.Value = "=IF(ISERROR(" & mystr & "),0," & mystr & ")"
End If
End If
Next
End Sub


Gord Dibben MS Excel MVP

On Thu, 25 Mar 2010 20:11:01 -0700, Rohit
wrote:

hi, i have various worksheets and within that worksheet there are cells
having #DIV/0!. I want this to be replace by zero. i know there is a
formula which will give out zero but if someone can write a macro would good.

Thanks