Keeping track of Excel VBA Variable values when debugging code

We’ve written a post on the VBA Intermediate Window and explained how it can be used to question the value of a VBA variable.

There is another way to show active variables and their values (if they have one) along with the variable’s data type etc.

Load the Locals Window from the View menu…


When displayed, the window will be blank until you are running through code…


Start stepping through and you will see that the variable var1 that I defined is now listed in the Locals window. The value is zero because I stopped before the value was assigned…


Once the variable has been assigned a value the value is displayed in the value column of the Locals window…


And that is it. Whatever point you are in you macro’s code you can load up the locals window and see exactly what is happening with all your variables. Very helpful when debugging code and if you have lots of variables being used.

3/5 (2)

Please rate this