+ Reply to Thread
Results 1 to 3 of 3

Search Range for NAs and pop up with a message box

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-05-2012
    Location
    Washington
    MS-Off Ver
    Excel 2013
    Posts
    110

    Search Range for NAs and pop up with a message box

    I am having trouble with a portion of my code.

    currently I am using this code I found

    Dim cell As Excel.Range
    For Each cell In Selection
    If WorksheetFunction.ISNA(cell) = True Then MsgBox ("#NA")
    Next cell
    
    Application.ScreenUpdating = True
    To search through a selected range with forumulas and if there is NA value, put up a message box with "#NA". It works but is not exactly what I am looking for. The code will put up a message box for each NA it finds (I know that is what it is suppose to do).

    . I am looking for a code that will evaluate the selected range and if it finds 1 or more "NA" then pop up 1 message box and then end sub. I have combed the internet but this code is the closest I can find to what I am looking for. I am trying to avoid writting a code that will evaluate 1 cell at a time as my range can be as large as 10,000 cells Any help would greatly be appreciated.

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Search Range for NAs and pop up with a message box

    Consider:

    Sub NATest()
        Dim cell As Range
        For Each cell In Selection
            If WorksheetFunction.IsNA(cell) = True Then
                MsgBox ("#NA")
                Exit For
            End If
        Next cell
    End Sub
    Gary's Student

  3. #3
    Forum Contributor
    Join Date
    10-05-2012
    Location
    Washington
    MS-Off Ver
    Excel 2013
    Posts
    110

    Re: Search Range for NAs and pop up with a message box

    That worked perfect thank you. I didn't even think about the 'exit for' command.

+ 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