Checking values ​​of public variables in Excel VBA - Locals Window Alternative

I use the Locals window to check procedure level variable assignments.

I recently updated my code to create a set of general level variables that read specific inputs from sheets that do not change from project to project.

When you try to check these variables, I do not see them in the Locals window, no doubt, because they are not locally defined variables!

Is there an alternative to the Locals window for public variables? And if not, how should I check public destination variables?

+6
source share
2 answers

In addition to the Immediate window (as described in another answer), the viewport is very useful in these circumstances. You can activate it in the menu "View" → "View window": enter image description here

Here you can define:

  • Any variable (e.g. your public variables)
  • Full term, for example. ActiveWorkbook.UsedRange.Address
  • The volume of all hours
  • Even a breakpoint when a value changes or appears in True is very convenient for debugging, as it allows you to quickly set conditional breakpoints without adding additional code, for example. if you set the clock to myVar=0 and are active. Break when the value is true, the code will automatically stop the moment when a potential error is triggered.

You can add all these parameters in the “Add Clock” dialog box, which you will either get by right-clicking on any variable (or other code) in the code module or by right-clicking in the viewer:

enter image description here

In addition, you can simply edit any display items in the list by double-clicking.

A very convenient tool for debugging, especially. in combination with locales and instant windows.

+13
source

Use the Immediate Window. Press Ctrl + G in your encoding to go to the immediate window. It allows you to get and set the value of your variable when you are in debug mode. Do you need a prefix? to check the value of a variable. Example

  ?variableName press enter to get the value variableName ="test" press enter to set the value 
+7
source

All Articles