testing for #NA with VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using VBA to loop through a range and if the cell contains an Excel
generated "#NA" I want to skip executing the functions in the loop.

To test for the "NA" I have tried the following:

If ActiveCell.Offset(idx1, 0).Value <> "Error 2042" Then _
and
If ActiveCell.Offset(idx1, 0).Value <> "#NA" Then _

and both give a "Run-time error '13': Type mismatch".

How can I test for an Excel generated '#NA' in a cell?

TIA
Tim Kredlo
Exterior Wood, Inc
 
Hi Tim,

Try this

Dim fErr As Boolean
On Error Resume Next
fErr = ActiveCell.Value = CVErr(xlErrNA)
On Error GoTo 0
If fErr Then MsgBox "#N/A"


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Back
Top