Debugging Macros

Kx ra Visual Basic Editor has three different modes in which it operates. In the Design mode, you can create new VBA procedures. You activate the Run mode, and thus execute the currently selected procedure, by clicking the Run Sub/UserForm button (1^), or by pressing F5.

VBE places you in the Break mode whenever the execution of a procedure stops due to a break point, a Stop statement in the code, a Watch statement, or when it encounters an error during execution. Whatever the cause of the break in execution, the Visual Basic Editor highlights the line of code that caused the error. To remind you that the Editor is in Break mode, the word break appears in the caption of the title bar at the top of the window. To exit out of Break mode, click the Reset button ([■").

You can clear a break point from your code by simply clicking it with the mouse. You should remember to clear all break points after you complete debugging your code.

1 Microsoft E tcel Object! Sj] 5heetl (Sheetl) a] Sheet; (Sheets Sj] Sheet: (Sheetîl I I Th 15Workbook r Modules J.': Modulel Ä Module! Module;

d SetBreaks( ) ti Aver age Val As Long b Nuifll A3 Long o Nuiti2 As Long b Nubj3 As Long ti Num4 As Long r.JJ.r T]

1 Microsoft E tcel Object! Sj] 5heetl (Sheetl) a] Sheet; (Sheets Sj] Sheet: (Sheetîl I I Th 15Workbook r Modules J.': Modulel Ä Module! Module;

|Module3 Module Alphabetic |

d SetBreaks( ) ti Aver age Val As Long b Nuifll A3 Long o Nuiti2 As Long b Nubj3 As Long ti Num4 As Long

L-Q Click the Run Sub/UserForm button (Q).

-■ The values of the locally declared variables display in the Locals window.

S Click Run Sub/UserForm to continue execution of procedure to the next break point.

-■ The values of the locally declared variables display in the Locals window.

S Click Run Sub/UserForm to continue execution of procedure to the next break point.

0 0

Post a comment