+ Reply to Thread
Results 1 to 3 of 3

Search VBA causing error when data isn't there to find

  1. #1
    Registered User
    Join Date
    01-20-2008
    Posts
    26

    Search VBA causing error when data isn't there to find

    Hi,

    I'm creating some code that basiclly checks to see if a code is there before proceeding with the rest of the script. I can make it find existing codes and tell me that it's there but if I enter one that isn't there it freaks out and goes into debugging.

    I need a way of stopping it from chucking a fit when the code doesn't already exist.

    My current code is as follow;

    Please Login or Register  to view this content.

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

    The result returned by Find in VBA is a Range object. You should always assign a Range object to Find to properly check if it was successful. See below...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross
    Last edited by Leith Ross; 03-11-2008 at 09:03 PM.

  3. #3
    Registered User
    Join Date
    01-20-2008
    Posts
    26
    Hi Leith,

    Thanks for the re worked code however this code is causing a strange problem when I call it.

    The Sub i'm calling the ChkJobNo from has code in it to check cells to see if there's anything in them and if not it brings up a message box telling you that there should be and then copies info from one sheet to another.

    When I call ChkJobNo and the number isn't found which it's searching for it causes the other Sub code to think there are empty cells when there are not.

    Why is this happening? The ChkJobNo is called at the top of the other subs code. I'll actually paste the other sub code below for your reference.

    Please Login or Register  to view this content.

+ 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