halt macro execution, inspect progress and then resume execution

  • Thread starter Thread starter John
  • Start date Start date
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?
 
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.
 
Back
Top