View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default How to recognise "#N/A"

On Tue, 29 Aug 2006 00:18:01 -0700, ch wrote:

I have a program and I saw some of the cells having "#N/A"

I wish to have excel delete its cell content if encounter this value.
eg. If activecell.value = "#N/A".

However, excel gave me a "type mismatch" error.

How can I overcome this?

Please help. Thanks.


Try this:

======================
Option Explicit
Sub clearNA()
Dim c As Range
Set c = [a1]

If IsError(c.Value) Then
If c.Value = CVErr(xlErrNA) Then
c.ClearContents
End If
End If

End Sub
=========================
--ron