Microsoft Office Tutorials and References
In Depth Information
Testing and Debugging Your Functions
In this case, the problem is the use of the And operator instead of the concatenation operator
( & ). The correct statement is as follows:
When you click the Debug button, the procedure is still running — it’s just halted and is
in break mode. After you make the correction, press F5 to continue execution, press F8
to continue execution on a line-by-line basis, or click the Reset button (in the Standard
toolbar) to halt execution.
Setting a breakpoint in the function
Another debugging technique is to set a breakpoint in your code. Execution pauses when VBA
encounters a breakpoint. You can then use the Immediate window to check the values of your
variables, or you can use F8 to step through your code line by line.
To set a breakpoint, move the cursor to the statement at which you want to pause execution and
choose Debug
Toggle Breakpoint. Alternatively, you can press F9, or you can click the vertical
bar to the left of the code window. Any of these actions highlights the statement to remind you
that a breakpoint is in effect (you also see a dot in the code window margin). You can set any
number of breakpoints in your code. To remove a breakpoint, move the cursor to the statement
and press F9. Figure 23-10 shows a Function procedure that contains a breakpoint.
Figure 23-10: The highlighted statement contains a breakpoint.
Search JabSto ::

Custom Search