View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Replacing an ERROR message with "NA"

To change all at once use this macro after selecting your used range on the
sheet.

It will ignore cells without formulas.

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 & "),""NA""," & myStr & ")"
End If
End If
Next
End Sub


Gord Dibben MS Excel MVP


On Thu, 13 Jul 2006 12:44:01 -0700, COL wrote:

I have created a table and some of the cells display the message "#DIV/0"
which I expected would happen, yet I want to automate the document so that
all error messages are replaced by the text message "NA". It's a large
document and it would take a very long time to change each cell manually so I
was hoping someone could help me. I also update it often, therefore I need to
keep the formula in the cell and if I type NA in the cell the formula will be
erased...

Does anybody know how to fix this?