1. Project explorer
Each Excel sheet (called object in VBA) has its own code window. Double click any object on the Project Explorer tree to see its associate code window. If this window is not visible press
Ctrl + R keys or click View from the top menu and then click Project Explorer.
- Microsoft Excel Objects
Store code for a worksheet. You’ll see multiple worksheet object if workbook contain more than one sheets (i.e. Sheet1, Sheet2, Sheet3 and so on).
Store code for the entire workbook which can access all sheets.
The Modules tree shows all independent code modules inserted on the current workbook. When the Macro Recorder created the
todayDatemacro it also created a module
Module1in which to store the macro. To see the VBA code in that module, you can double-click the module name. The
todayDatemacro appears in the Code window for
2. Properties window
The Properties window lists the properties for selected objects and their current settings. This list depends on what is currently selected. If this window is not visible press
View > Properties Window from the menu.
3. Code window
A Code window is where you put your VBA code. Every object in a project explorer has an associated Code window. To view an object’s Code window, double-click the object in the Project explorer.
4. Immediate window
This window can be opened through the View menu or with the
Ctrl + G key combination. The Immediate window is useful for issuing a VBA commands. If you type a command and press Enter, the command takes effect immediately. For example, writing
range("a1","g10").select in Immediate window and pressing enter will select the range
A1:G10 of the current worksheet. To see, switch back to Excel workbook, you will see that the range A1:G10 has been selected:
If you precede the command by a question mark, you can get an immediate answer to a question. For example, if you type
?range("a1").value, you immediately get the answer on the 2nd line:
5. Watches window
The Watch window is used for debugging. You can put a watch on one or more key variables to see how they change as the program progresses.
The Locals window is also used for debugging. It provides easy access to the current value of variables and objects within the scope of the function or subroutine you are running. It is an essential tool to debugging your code and stepping through changes in order to find issues.