+ Reply to Thread
Results 1 to 3 of 3

Stopping VBA Search from showing error if searched item does not exist

  1. #1
    Registered User
    Join Date
    11-20-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    1

    Stopping VBA Search from showing error if searched item does not exist

    Hello, I have a piece of code that searches the M column for an entered number. However, the purpose of the search is to confirm that the number im searching doesn't exist. I mean, I have an excel file with thousands of numbers in the M column, so when given a new number for the column, I want to be sure there isn't a duplicate number in that column. Here is what I have so far:
    Please Login or Register  to view this content.
    How can I prevent it from showing the error message, and instead show a message box that says "Number does not exist" ?

    Thank you for reading my question,

    Johnny O
    Last edited by Leith Ross; 01-26-2013 at 09:31 PM. Reason: Added Code Tags

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Stopping VBA Search from showing error if searched item does not exist

    Something like this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Stopping VBA Search from showing error if searched item does not exist

    Hello Johhny O,

    Welcome to the Forum!

    By assigning a Range object variable to the Find result, you can then test if the value was found or not. The Find method will return either a reference to cell where the value was found or the special object value Nothing.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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