Stepping Through a Procedure
One of the most common (and most useful) debugging techniques is to step through the code one statement at a time. This lets you get a feel for the program flow to make sure that things such as loops and procedure calls are executing properly. You can use three techniques:
Stepping into a Procedure
Stepping into a procedure means you execute one line at a time (in break mode), starting at the beginning of the procedure. If you haven't started a procedure yet, you step into it using the technique described in the section "Entering Break Mode at the Beginning of a Procedure."
Alternatively, you might prefer to run your code until it's about to call a particular procedure, and then step into that procedure. To do this, set a breakpoint on the statement that calls the procedure. Once your code hits that breakpoint, step into the procedure by selecting the Debug, Step Into command (or by pressing F8).
Once you're inside the procedure, repeat the Step Into command to execute the procedure code one line at a time. Keep stepping through until the procedure ends or until you're ready to exit break mode and resume normal execution.
Stepping Over a Procedure
Some statements call other procedures. If you're not interested in stepping through a called procedure, you can step over it. This means that VBA executes the procedure normally and then resumes break mode at the next statement after the procedure call. To step over a procedure, first either step into the procedure until you come to the procedure call you want to step over, or set a breakpoint on the procedure call and run the project. Once you're in break mode, you can step over the procedure by selecting Debug, Step Over (or by pressing Shift+F8).
Stepping Out of a Procedure
It's very common (and very frustrating) to accidentally step into a procedure that you wanted to step over. If the procedure is short, you can just step through it until you're back in the original procedure. If it's long, however, you don't want to waste time going through every line. Instead, invoke the Step Out feature by selecting Debug, Step Out (or by pressing Ctrl+Shift+F8).
VBA executes the rest of the procedure and then re-enters break mode at the first line after the procedure call.
Stepping to the Cursor
Instead of stepping over an entire procedure, you might need to step over only a few statements. To do this, enter break mode, place the insertion point inside the line where you want to re-enter break mode, and then select Debug, Run To Cursor (or press Ctrl+F8).