Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default testing for #NA with VBA

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default testing for #NA with VBA

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" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default testing for #NA with VBA

Tim,

Try this:

Sub xxx()

If IsError(Activecell) Then

MsgBox "Hi"

End If

End Sub


--
rand451
"Tim Kredlo" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Testing Jay T. Emory[_2_] Excel Discussion (Misc queries) 0 February 18th 09 08:55 PM
TESTING Eamon Excel Worksheet Functions 0 July 11th 08 03:41 PM
Testing Richard Wrigley Excel Discussion (Misc queries) 0 November 1st 06 09:45 PM
Testing Tony Excel Discussion (Misc queries) 0 June 4th 05 05:39 PM
just testing John Excel Programming 1 August 30th 04 05:16 AM


All times are GMT +1. The time now is 04:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"