Step Through Code
When you are writing or maintaining code it is very useful to be able to step through the code one line at a time.
This can help you see what each line of code is doing and can help you understand complicated blocks of code.
As each line of code is executed, the appropriate action is taken and the corresponding line is highlighted in yellow.
Pressing F8 will execute the code one line at a time.
Immediately before a line containing a break point is executed the line will appear with a yellow background.
Dim iNumber As Integer
Dim sText As String
iNumber = 10
iNumber = iNumber * 2
sText = iNumber
Dim iLoop As Integer
For iLoop = 1 To 10
Stepping through code - simple screenshots of the yellow bar
Once your code has been stopped, by a break point or by stepping through your code you can resume execution by pressing (Run > Continue( or F5. To end the macro press (Run > Stop ??).
This causes execution to stop at the line after the call to this procedure.
Auto Data Tips
(Tools > Options)(Editor tab)
This displays the value of a variable as a tooltip when you hover it with the mouse
Run to Cursor
This allows you to execute code and then enter break mode on the line containing the cursor. This is similar to putting a break point on a line, although "running to cursor" is temporary and will not have an effect the next time the code is executed.
Changing statement execution order: While execution of your code is halted you can control the execution sequence of statements within a procedure. To set the next statement to be executed position the insertion point anywhere in the code and go (Debug > Set next statement) or press (Ctrl + F9). Alternatively just drag the yellow arrow to the corresponding line.
Whenever you are doing lots of debugging it is worth saving your modules (i.e. exporting them) every 10/15 minutes as VBA has a tendency to crash if you are undertaking mammoth debugging sessions.
SS of error message
The line highlighted in yellow is the next line to be executed
All macros can be stopped at any time by pressing (Ctrl + Break).
If a procedure appears to be hanging you can normally interupt it by pressing (Ctrl + Break).
© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited TopPrevNext