totn Excel 2010 VBA Debugging

MS Excel 2010: Debug Mode in VBA

This Excel tutorial explains the debugging mode in the VBA environment in Excel 2010 (with screenshots and step-by-step instructions).

Debug Mode

Now that we know how to set and clear breakpoints in Excel 2010, let's take a closer look at the debug mode in VBA.

In our example, we've set our breakpoint and entered our CustomRound function as a formula in a cell. This will cause the VBA code to execute.

Microsoft Excel

When the breakpoint is reached, Excel will display the Microsoft Visual Basic window and highlight the line (in yellow) where the code has been suspended.

Microsoft Excel

Now we are in debug mode in our Excel spreadsheet. Now we can do any of the following:

  1. Check the value of a variable in its current state.
  2. Enter VBA code in the Immediate window to view the results.
  3. Execute each line of code one at a time.
  4. Continue execution of the code.
  5. Halt execution of the code.