Stopping Macro via Command Button, with Confirmation.

screech

Active Member
Joined
May 27, 2004
Messages
296
Can someone help me to come up with the code to stop or break a running macro via a command button on a userform? I have two buttons on the userform, one to click when the macro is complete to unload the userform (I have the code for that) and another to stop the macro dead in its tracks while it is running if it is taking too long. Instead of the user pressing Ctrl + Break, I would rather have them click on a button.

Also, if I do this by a command button code, could I get a message box to pop up to ask "Are you sure?" just to confirm the macro should be stopped, and if the answer is no, then the macro will continue where it left off?

Thanks so much for all your help! You guys and gals are great.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
I don't think this will work. I checked out the CheckKey example and it has the code placed inside a loop and uses the "Loop Until" command to tell it when to break out of the loop to end the function. My macro contains a bunch of operations, like copying and pasting and several loops and calculating that it's just not one big loop but an automated series of events, one after another.

I was thinking more of the VBA code for Ctrl+Break and assign it to the Button_Click code for the command button ... if possible.
 
Upvote 0

Forum statistics

Threads
1,224,879
Messages
6,181,530
Members
453,054
Latest member
ezzat

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top