ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Button To Cancel Macro (https://www.excelbanter.com/excel-programming/271850-re-button-cancel-macro.html)

Bill Lunney

Button To Cancel Macro
 
To release some CPU time insert a DoEvents statement into the mainloop of
your code.

Pressing ESC while a macro is running will stop the code. If you have Excel
2000 or above you can show a 'modeless' form. Versions of Excel prior to
this only allow you to display a form which will not relenquish control to
the worksheet until the form dissapears.

Use something like frmTest.Show True to display the form in modeless mode.
This way you can put a Cancel button or something similar on the form, show
it, execute your code as normal. Insert the relevent code into the click
event of the cancel button and then this allows the user to cancel an
operation.

Look at this page for a detailed explanation.

http://www.billlunney.com/Excel/FAQ/...?ExcelFAQID=51


--

Regards,


Bill Lunney
www.billlunney.com

"Alex Wolff" wrote in message
...
Hello,

I have seen a couple of posts on this already but still
not sure how to do it.

When my macro starts I want to display a button that gives
the user the opportunity to "Cancel".

Also while the macro is running it seems to suck up all
the CPU time. How do I keep my macro from sucking all CPU?

Thanks.





All times are GMT +1. The time now is 05:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com