Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default 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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get userform Cancel button to invoke Exit Sub in calling macro? Craig Remillard New Users to Excel 1 November 19th 09 03:55 AM
Workbook_BeforeClose(Cancel As Boolean) - Cancel won't work gpmichal Setting up and Configuration of Excel 1 May 12th 09 02:33 AM
Macro screen- everything but Run and cancel is greyed out [email protected] Excel Discussion (Misc queries) 6 October 25th 07 08:50 PM
message box without ok or cancel button Subash Excel Discussion (Misc queries) 1 October 18th 05 10:38 AM
Cancel a Link and a Macro Ben Blair Excel Discussion (Misc queries) 1 July 5th 05 08:54 PM


All times are GMT +1. The time now is 08:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"