+ Reply to Thread
Results 1 to 6 of 6

Stop Macro after cancel is on vbCancel is clicked

  1. #1
    Registered User
    Join Date
    02-06-2012
    Location
    NYC, US
    MS-Off Ver
    Excel 2010
    Posts
    19

    Stop Macro after cancel is on vbCancel is clicked

    How do you use vbOKCancel to exit out of a macro? Here is my attempt, but even though I press cancel, my macro continues running.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Stop Macro after cancel is on vbCancel is clicked

    Try this

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-06-2012
    Location
    NYC, US
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Stop Macro after cancel is on vbCancel is clicked

    Thanks, it worked if false is used without quotation marks.

  4. #4
    Registered User
    Join Date
    02-06-2012
    Location
    NYC, US
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Stop Macro after cancel is on vbCancel is clicked

    Wait,

    When I tried to use the macro, it exited before completing its task even though I didn't click cancel. The problem is only in the last prompt (i.e. if I get rid of the vbCancel mechanism here, it works even though they are in the other ones). What can I do?

    Please Login or Register  to view this content.
    If I delete this, it works, however, I want the option of cancelling out of this box.
    Please Login or Register  to view this content.
    Last edited by juliorevka; 03-08-2012 at 04:28 PM.

  5. #5
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Stop Macro after cancel is on vbCancel is clicked

    This seems to work OK.

    Please Login or Register  to view this content.

  6. #6
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Stop Macro after cancel is on vbCancel is clicked

    BTW, InputBox does not have a Buttons argument, it only has OK and Cancel buttons. So, where you are putting vbOKCancel, that is not setting the buttons, it is setting a default value of 1 (vbOKCancel is a constant value 1).

+ 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