halt macro execution, inspect progress and then resume execution

J

John

I would like to halt the execution of a complex macro at a specific
location in the code and then navigate around several worksheets
(maybe even look at some different workbooks) and after I'm done
inspecting I would like to resume the macro execution at the same
point where it was halted.

What is the recommended method for doing something like this?
 
J

joeu2004

John said:
I would like to halt the execution of a complex macro at a specific
location in the code and then navigate around several worksheets
(maybe even look at some different workbooks) and after I'm done
inspecting I would like to resume the macro execution at the same
point where it was halted.
What is the recommended method for doing something like this?

You can sprinkle Stop statements at key junctures in your macros.

Alternatively, you can set breakpoints by pressing F9 with the cursor
hovering over a statement. You can also use F8 step through the code and
ctrl+F8 to run to the statement where the cursor is hovering.

If your macros loops, you can pause execution randomly by pressing
ctrl+alt+Pause (on my computer).

Alternatively, you might at logic to execute the Stop statement when a
certain condition is met, for example when an iteration counter is a
specific value.

Press F5 when you are ready to resume execution.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top