Seeing the code while watching how it changes a worksheet is a powerful way to diagnose bugs. It's easy to do this by setting a breakpoint just before the place that there's trouble (Step 1 below).
Step 1. Inserting a breakpoint in code
Next, run the macro. When Excel reaches the breakpoint the debug window will appear. Step through the code using the step into and step over buttons (Step 2 below). The arrangement for windows and toolbars in Step 2 is especially handy for debugging. It makes the worksheet, debug window, and VBA toolbar visible while leaving ample space for editing the code.
Step 2. Stepping through code using the Debug Window