totn Excel 2013 VBA Debugging

MS Excel 2013: Set Breakpoint in VBA

This Excel tutorial explains how to set a breakpoint in the VBA debugging environment in Excel 2013 (with screenshots and step-by-step instructions).

What is a Breakpoint?

In Excel 2013, a breakpoint is a selected line of code that once reached, your program will momentarily become suspended. Once suspended, you are able to use VBA's debugging environment to view the status of your program, step through each successive line of code, continue execution of the code, or halt execution of the code.

You can create as many breakpoints in your code as you want. Breakpoints are particularly useful when you want to suspend your program where you suspect a problem/bug exists.

Setting a Breakpoint

Next, let's look at how to set a breakpoint.

First, you need to open the VBA environment. The quickest way to do this is by pressing Alt+F11 while your Excel database file is open.

To set a breakpoint, find the line of code where you'd like to suspend your program. Left-click in the grey bar to the left of the code. A red dot should appear and the line of code should be highlighted in red.

Microsoft Excel

In this example, we've created a breakpoint at the following line of code:

LChar = Mid(pValue, LPos, 1)