VBA & Macro Problems

Fix Excel VBA Restarting from Beginning After Breakpoint

Nimra MalikNimra Malik Oct 26, 2026 868 views

Question details

The user's Excel VBA project restarts from the very beginning when execution is resumed from a breakpoint, rather than continuing sequentially to the next statement.

Fix Excel VBA Restarting from Beginning After Breakpoint
Product
Excel VBA
Device & OS
Windows 11
Scenario
Debugging an infinite loop macro that incorporates Application.Wait or Application.OnTime functions.
Observed behavior
When the macro execution hits a breakpoint and the user attempts to resume it, the code starts over from the first line instead of proceeding from the paused line.
Before you start

Before troubleshooting, manually compile your VBA project to check for syntax errors and ensure you have disabled any background event triggers that might reset the execution state.

Solution 1Recommended

Check for Conflicting Application.OnTime Events

Determine if an asynchronous OnTime event is firing while your code is paused, which can reset the VBA execution state.

While Application.Wait suspends the entire Excel application, preventing breakpoints from being hit during the wait, Application.OnTime schedules an event asynchronously.

If an OnTime event is triggered exactly when your VBA environment is paused at a breakpoint, it can cause the interpreter to clear the current execution state and restart.

1
Open the VBA Editor

Press Alt + F11 to open the Visual Basic for Applications (VBA) editor.

2
Search for OnTime Events

Press Ctrl + F and search for 'Application.OnTime' across the 'Current Project'.

3
Disable Triggers During Debugging

Temporarily comment out the Application.OnTime lines by placing an apostrophe (') at the beginning of the line, then test your breakpoint again to see if the restart behavior stops.

Check for Conflicting Application.OnTime Events
Execution State Reset: Any action that forces the VBA project to reset, such as editing active variables, clicking the Stop (Reset) button, or certain asynchronous events firing, will cause the code to start from the beginning on the next run.
Free Microsoft Office alternative

Try WPS Office for Reliable Macro and VBA Execution

If you are experiencing persistent anomalies with Excel's VBA execution states or debugging environment, consider switching to WPS Office. It provides a robust and stable environment for complex spreadsheet macros without the heavy resource usage.

Highly compatible with Microsoft Excel macro formats (.xlsm, .xltm)Stable built-in VBA editor and debugging environmentFree, lightweight, and fast-loading spreadsheet applicationFamiliar user interface for seamless and easy migration
microsoft office alternative - wps office

Frequently Asked Questions

What is the difference between Application.Wait and Application.OnTime in VBA?

Application.Wait pauses the entire Excel application for a specified duration, meaning VBA cannot hit a breakpoint while waiting. Application.OnTime schedules a specific macro procedure to run at a future time, allowing Excel to remain active and process other commands in the meantime.

Why does editing code during a breakpoint reset the macro?

Making structural changes to your code while in Break Mode (paused) often requires the VBA compiler to reset the project. When this happens, all variables lose their values, the execution state is cleared, and running the macro again will start it from the beginning.

How do I safely interrupt an infinite loop in Excel VBA?

You can break an infinite loop by pressing Ctrl + Break (or Ctrl + Pause) on your keyboard. On laptops without a Pause/Break key, pressing Esc repeatedly or Ctrl + Scroll Lock often achieves the same result, prompting a dialog where you can click 'Debug' to pause the code.