+ Reply to Thread
Results 1 to 3 of 3

Message Box: Continue with Macro or cancel process

Hybrid View

  1. #1
    Registered User
    Join Date
    07-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    88

    Message Box: Continue with Macro or cancel process

    Hi all,

    I have a workbook that contains a macro that completes a process then clears all information from the workbook. I want to insert a message box that comes up first when the macro is run, that informs the user that running the macro will clear the workbook. If the user chooses "Yes", then the macro will continue to run, clearing the workbook in the process.

    The user might not have realized that the macro will clear all of the data, and may wish to look over the data before it gets deleted. If the user clicks "No", then the macro will stop and not run the rest of the program. Is this something that can be easily done? I think I can get the macro to continue running if "yes" is selected, but I'm clueless about how to make it stop running if the user chooses "no".

    Thank you for taking the time to read my question.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,368

    Re: Message Box: Continue with Macro or cancel process

    Hi Student,

    I'm looking at
    http://msdn.microsoft.com/en-us/libr...ffice.15).aspx
    that gives me all those extra parameters to message boxes....

    See my example to see if it helps.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    07-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Message Box: Continue with Macro or cancel process

    Thank you, MarvinP. I looked around on the Microsoft site for awhile, and then came up with a solution to my problem. I wanted my macro to continue processing if the user clicks "Yes", but to do nothing if the user clicks "No". I was hoping to find some code that makes the macro stop running when entered - it doesn't pause the macro but just ends the program right then and there. This way, if the user clicks "no" in the message box, the macro won't continue to run and delete all the data in the workbook. It will simply stop itself there.

    My solution isn't complicated, but I just decided to create a separate macro for the message box. Using an IF statement, if the user selects "Yes", then the macro will continue to run by calling the original macro

    Call Macro12
    If the user selects "No", (else) the macro will simply select an active cell in the workbook and end the program, deleting no content.

    Again, thanks to MarvinP for the direction.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 08-23-2013, 05:45 PM
  2. Message Box Prompt. Continue Or Cancel
    By ashleys.nl in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-12-2011, 02:30 PM
  3. Userform - Continue and cancel command buttons code
    By Jessica.Bush in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-01-2010, 04:42 PM
  4. Cancel QueryTables.Refresh Process After 10 Seconds
    By MCP in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-02-2005, 02:05 PM
  5. [SOLVED] Macro Pause, show message, continue
    By davegb in forum Excel General
    Replies: 3
    Last Post: 02-11-2005, 01:06 PM

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