+ Reply to Thread
Results 1 to 5 of 5

GoTo NotFound

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    GoTo NotFound

    I’m preceding a Selection.Find with On Error GoTo NotFound

    Is this going to GoTo NotFound on ANY and ALL ERRORS?
    Is there a way to say if the Selection is not Found go to NotFound?

            On Error GoTo NotFound
            
            Columns("EH:EH").Select
                Selection.Find(What:=NewEntry, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Select

  2. #2
    Registered User
    Join Date
    06-11-2007
    Location
    Nonthaburee Province, Thailand
    MS-Off Ver
    MS Office 2003 to MS Office 2010
    Posts
    82
    Because you forgot to place subroutine name NotFound

    Correct this code

    On Error GoTo NotFound

    Columns("EH:EH").Find(What:=NewEntry, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)

    NotFound:

    If Err.Number = ____ then
    Msgbox _______
    Else

    End if
    The underline is the code that you want to put it
    N. Yauvasuta
    Power User Excel.

  3. #3
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686
    Actually I do have "NotFound: " in my code, I just left it out of my post.

    I forced the error number to a msgbox and found it to be #91 but
    Is there a list of Error numbers somewhere?

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    This link should help

    http://support.microsoft.com/kb/146864

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  5. #5
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Once the on error command is run it is active for all errors until changed or turned off

    use
    On Error GOTO 0
    after your find command

    and of course read the artice that VBA Noob suggested
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

+ 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