PC Review


Reply
Thread Tools Rate Thread

testing for #NA with VBA

 
 
=?Utf-8?B?VGltIEtyZWRsbw==?=
Guest
Posts: n/a
 
      25th May 2005
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
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      25th May 2005
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)


"Tim Kredlo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
 
STEVE BELL
Guest
Posts: n/a
 
      25th May 2005
Tim,

Try this:

Sub xxx()

If IsError(Activecell) Then

MsgBox "Hi"

End If

End Sub


--
rand451
"Tim Kredlo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
testing testing testing wasted Windows Vista Mail 1 27th May 2008 04:17 PM
testing testing testing geedeesaved55 Windows Vista Mail 1 27th May 2008 03:22 PM
testing testing 1 2 3 =?Utf-8?B?QWFyb24gT3hmb3Jk?= Windows XP General 1 4th Dec 2005 03:34 PM
Unit testing and performance load testing Curtis Justus Microsoft C# .NET 2 19th Jan 2005 03:59 PM
Testing, testing... john Windows XP Internet Explorer 0 22nd Sep 2003 08:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:30 AM.