Visual basic interface
How to open the VBA environment
Select the Developer tab from the toolbar at the top of the screen. Then click on the Visual Basic option in the Code group.
Now the Microsoft Visual Basic editor should appear and you can view your VBA code.
Project Explorer
The Microsoft Visual Basic for Applications window displays your VBA environment in Excel 2010:
Next, let's take a few moments to analyze the various sections in the Microsoft Visual Basic window.
The Project Explorer can usually be found in the top left portion of the Microsoft Visual Basic window. It is a hierarchical listing of the objects recognized by VBA.
In this example, there are four Excel objects which represent each sheet and workbook in your Excel file - Sheet1, Sheet2, Sheet3, and ThisWorkbook.
There is also one module called Module1. The VBA code in Module1 can used anywhere in your spreadsheet. Whereas, the code within an Excel object is typically only used by that object.
If the Project Explorer is not visible when you open the Microsoft Visual Basic for Appliations window, you can make it visible by selecting Project Explorer under the View menu.
Properties Window
The Microsoft Visual Basic for Applications window displays your VBA environment in Excel 2010:
Next, let's analyze the Properties window in the VBA environment.
The Properties window is usually found directly below the Project Explorer in Excel 2010. It displays the properties for the object currently highlighted in the Project Explorer.
In the example above, it is displaying the properties for the module called Module1.
If the Properties Window is not visible when you open the Microsoft Visual Basic for Applications window, you can make it visible by selecting Properties Window under the View menu.
The Microsoft Visual Basic for Applications window displays your VBA environment in Excel 2010:
Next, let's analyze the Code window in the VBA environment. The Code window is usually found to the right of the Project Explorer in Excel 2010. It displays the VBA code for the object currently highlighted in the Project Explorer.
In the example above, it is displaying the VBA code for the module called Module1.
If the Code window is not visible when you open the Microsoft Visual Basic for Applications window, you can make it visible by selecting Code under the View menu.
Immediate Window
The Microsoft Visual Basic for Applications window displays your VBA environment in Excel 2010:
Next, let's analyze the Immediate window in the VBA environment.
In Excel 2010, the Immediate window is usually found below the Code window. It is an essential element of the debugger found within the VBA environment. It lets you:
- Type code and press ENTER to view the results of the code.
- When in debug mode, it lets you view the value of a variable in its current state. This will be discussed in the tutorial on Debugging VBA Code.
If the Immediate window is not visible when you open the Microsoft Visual Basic for Applications window, you can make it visible by selecting Immediate Window under the View menu.
Watch Window
The Microsoft Visual Basic for Applications window displays your VBA environment in Excel 2010:
Next, let's analyze the Watch window in the VBA environment.
In Excel 2010, the Watch window is usually found below the Code window. It is one of the most valuable tools when debugging in the VBA environment. It lets you:
- Define and monitor any expression.
- When in debug mode, it lets you view the value of the watched expression in its current state. This will be discussed in the tutorial on Debugging VBA Code.
If the Watch window is not visible when you open the Microsoft Visual Basic for Applications window, you can make it visible by selecting Watch Window under the View menu.