+ Reply to Thread
Results 1 to 6 of 6

Option to Exit Macro Via Message Box

  1. #1
    Registered User
    Join Date
    10-18-2010
    Location
    Vancouver, BC
    MS-Off Ver
    Excel 2007
    Posts
    47

    Option to Exit Macro Via Message Box

    Hello, I am wondering how to write a code that checks the number of workbooks open and, if it is more that one, pops up a message box giving the option to exit the macro by pressing no or cancel. I have successfully gotten the message box to show but cannot get the additional NO button to work correctly. Thank you!
    Last edited by kirsty; 12-12-2010 at 03:05 AM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Option to Exit Macro Via Message Box

    Hi kirsty
    hard to say with out code but maybe...
    Please Login or Register  to view this content.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Registered User
    Join Date
    10-18-2010
    Location
    Vancouver, BC
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: Option to Exit Macro Via Message Box

    Thank you very much pike. This works to get both Yes and No buttons to show however neither response exits the macro on my computer? If I answer "No" I need the macro to exit. Do you know how to modify the code to do that?

  4. #4
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Option to Exit Macro Via Message Box

    Hi kirsty

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-18-2010
    Location
    Vancouver, BC
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: Option to Exit Macro Via Message Box

    Hey, thank you very much. I was able to tweak it to do what I needed. Have a nice weekend!

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Option to Exit Macro Via Message Box

    FYI, all....

    Since you only really need to "do" something specific if one answer is given, you can slim that down to one command:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ 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