MS Excel 2011 for Mac: Using the Immediate Window
This Excel tutorial explains how to use the Immediate Window in the VBA debugging environment in Excel 2011 (with screenshots and step-by-step instructions).
See solution in other versions of Excel:
Using the Immediate Window
In Excel 2011, the Immediate window can be used to debug your program by allowing you to enter and run VBA code in the context of the suspended program.
We've found the Immediate window to be the most help when we need to find out the value of a variable, expression, or object at a certain point in the program. This can be done using the print command.
For example, if you wanted to check the current value of the variable called LWhole, you could use the print command as follows:
In this example, we typed print LWhole in the Immediate window and pressed ENTER.
print LWhole
The Immediate window displayed the result in the next line. In this case, the print LWhole command returned 800.
You can also type more complicated expressions in the Immediate window. (Remember to press ENTER.) For example:
In this example, we typed print Int(pValue) in the Immediate window and pressed ENTER.
print Int(pValue)
The Immediate window displayed the result of 800 in the next line.
The Immediate window can be used to run other kinds of VBA code, but bear in mind that the Immediate window can only be used when debugging so any code that you run is for debugging purposes only. The code entered in the Immediate window does not get saved and added to your existing VBA code.
Advertisements