ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using code to stop a macro. (https://www.excelbanter.com/excel-programming/308833-using-code-stop-macro.html)

Wrightr

Using code to stop a macro.
 
In VBA, is there any way you can write a macro that can
stop another macro currently executing. I have a macro
that loops for over 30 minutes. I would like to be able
to write another macro that allows me to neatly stop the
first macro. I can't see anything in VBA that allows you
to do this - especially since it doesn't seem possible to
launch a second macro (using a macro button) when another
macro is still executing.
Is there a work-around?

Bob Kilmer

Using code to stop a macro.
 
If have dominion over the long-running macro code, you can modify it to
check the status of something, like a key press, cell value or an
environment variable, and exit if the status attains a certain value. If the
macros has a form, you can implement a cancel function. But, no you cannot
start one Excel macro that will end another.

"Wrightr" wrote in message
...
In VBA, is there any way you can write a macro that can
stop another macro currently executing. I have a macro
that loops for over 30 minutes. I would like to be able
to write another macro that allows me to neatly stop the
first macro. I can't see anything in VBA that allows you
to do this - especially since it doesn't seem possible to
launch a second macro (using a macro button) when another
macro is still executing.
Is there a work-around?





All times are GMT +1. The time now is 07:16 PM.

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