Watching a Procedure Execute

When you run procedures that use looping structures, it's sometimes hard to see whether the procedure works as expected. Occasionally, you'd like to watch the procedure execute in slow motion so that you can check the logic of the program. Let's see how Visual Basic allows you to execute a procedure line by line.

1. Enter any data in cells A1:A5. Select cell A1.

In the Microsoft Excel window, choose Tools | Macro | Macros. In the Macro dialog box, select the ApplyBold2 procedure and click the Step Into button. The Visual Basic Editor screen will appear with the name of the procedure highlighted in yellow (see Figure 6-1). Notice the yellow arrow at the left of the Code window.

Make the Visual Basic window smaller. To do this, click the restore button in the Visual Basic title bar and arrange the screen as shown in Figure 6-1.

Press F8. The yellow highlight in the Code window jumps to the line DoUntil IsEmpty(ActiveCell).

Continue pressing F8 while watching both the Code window and the worksheet window.

Figure 6-1: Watching the procedure code execute line by line
0 0

Post a comment