
Make sure to delete them after you have finished debugging.Īfter you have paused your code, you can do some more experimenting before continuing. All pauses are marked with dark red color. Once you click Run, the code will make a pause there and you can investigate your variables and output value. To do that you need to select a line of code which will serve as pause, and press F9 or click on the Toggle Breakpoint. While testing a pretty long code, sometimes you want to pause and inspect what has been done thus far. This process can be extremely useful in testing and running your code. For example, if you have 100 iterations, you will be able to follow each of them. If you have loops in your code, each step in the process will be executed one by one. Every time you press F8, the next line will be executed. Press F8 once more and the yellow mark will move to the next line. Open your code, select the first line and press F8. Running each step of the process one by one can help you identify where the bottleneck is. It certainly won’t be easy to find the problem if you run your code all at once. To avoid such situations, it can be helpful to use some of the debugging tools that come with Microsoft Excel. Hours can be spent searching for the mistake, without success.

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.When code is not working as it should, it can be hard to locate the error if you have multiple lines of code. To stop execution when the value of the expression changes, choose Break When Value Changes. To stop execution if the expression evaluates to True, choose Break When Value is True.

To display the value of the watch expression, choose Watch Expression. Select an option in the Watch Type group to define how the system responds to the watch expression. Choose Call Stack from the View menu to display the list of active procedures. If you select a specific procedure for a context, execution is affected only while the procedure is in the list of active procedure calls.

Selecting all procedures or all modules can slow down module execution considerably, because the expression is evaluated after execution of each statement. Select the narrowest scope that fits your needs.
