+ Reply to Thread
Results 1 to 5 of 5

On Error Resume Next

  1. #1
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,165

    On Error Resume Next

    Why doesn't this code exit on the first "Cancel" selection from the first inputbox?
    When I select Cancel from the first inputbox it goes to the next inputbox and I have to select Cancel again, then it exits the sub.
    Please Login or Register  to view this content.
    Any hints, tips or examples are welcome.
    Last edited by Rick_Stanich; 01-20-2010 at 10:36 AM.
    Regards

    Rick
    Win10, Office 365

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444

    Re: On Error Resume Next

    Hi,

    If you press cancel, the inputbox will return an empty string (""), not generate an error.

    Please Login or Register  to view this content.
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: On Error Resume Next

    If sMyPath is declared as a String hitting Cancel won't generate an Error merely an empty String variable so the Err.Number will be 0.

    Also, beware how you're using your handlers... once you reset via the GoTo 0 it follows that were the 2nd InputBox to generate an Error (again not possible if using String variable) then the Resume Next is no longer active and would thus generate Debug.

    For more info. on handling see: http://www.cpearson.com/excel/ErrorHandling.htm

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,239

    Re: On Error Resume Next

    Alternatively, if you use Application.Inputbox instead, it will return False when you press Cancel.
    Remember what the dormouse said
    Feed your head

  5. #5
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,165

    Re: On Error Resume Next

    Thanks to all, skooled again.

+ 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