Wednesday, June 19, 2013

How to use Intermediate Window in VBA

Leave a Comment
The Intermediate window in the Visual basic Editor allows you to run the code at any time, right on the spot. This window is sometimes referred to as the debug window because it is mainly used for testing and debugging code (Remove the error from code). If the Intermediate window is not open in the Visual basic editor, you can bring it out of hiding at any time by choosing View Intermediate Window from the Visual Basic Editor menu’s bar.
The Intermediate Window allows you to test expression, run VBA procedure that you created and more. You will see the practical example throughout this article. To get you feet wet, test this example expression in the intermediate window. Just bear in mind that a VBA expression is any formula. For instance the simplest expression in the world is probably 1+1, which (as just about everyone knows) result is 2.

Testing Expression in Intermediate Window
To test an expression in the Intermediate Window, do the following
1. Click inside the Intermediate Window:
You need your cursor in the Intermediate Window

2. Type a question mark (?) follow by a space and the expression that you want to test and press Enter

For Example, Click in the Intermediate Window and then type ? 1+1. The Intermediate Window immediately show the result – 2 – as shown in the below figure


 Figure 1: Intermediate Window

You might think of the? Character at the start of the line as asking the Intermediate Window “What is?” For Example, if you think of ? 1+1 as meaning “What is 1 plus 1?”, it stands to reason that the Intermediate Window would return the result 2. After all, 1+1 is 2.

When you start actually writing VBA code, you will use the Intermediate Window to test and debug your code. For now, just know that the Intermediate Window is another optional pane in the Visual Basic Editor that you can show or hide as you needed.

0 comments :

Post a Comment