+ Reply to Thread
Results 1 to 3 of 3

testing for #NA with VBA

  1. #1
    Tim Kredlo
    Guest

    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. #2
    Bob Phillips
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #3
    STEVE BELL
    Guest

    Re: testing for #NA with VBA

    Tim,

    Try this:

    Sub xxx()

    If IsError(Activecell) Then

    MsgBox "Hi"

    End If

    End Sub


    --
    rand451
    "Tim Kredlo" <[email protected]> wrote in message
    news:[email protected]...
    >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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1