The VBA development environment - called Visual Basic Editor (VBE) - is where you will write and verify the code to perform Excel actions. There are a few ways to open the VBE:
You can also open VBE from the View tab $\rightarrow$ Macros, creating a new macro.
The VBE framework has several internal windows, the main ones being:
Advanced topics are recommended only after acquiring some experience in the subject. They are made available due to their proximity to the theme.
If any window does not appear, just enable it in the tab View $\rightarrow$ 'Desired Window'.
Initially we will use (1.) Project Explorer, (2.) Code Window, (3.) Toolbar and (4.) Menu bar windows.
We will gradually understand the function of each of these windows.
The Project Explorer or Project - VBAProject is the VBE window that lists hierarchically the loaded projects.
The VBAProject is created along with the Excel document (file) and every document has only one project.
In the example above, we have two projects, so we can immediately conclude that there are two open files in Excel ( Products.xlsm and Sales.xlsm). Note that VBE separates content into folders for organizing purposes.
Every VBA code resides inside an item in the VBE Project Explorer. The Code Window will show the VBA code that is within the selected item in the Project Explorer.
The Code Window is where all VBA code will be displayed and developed.
Every Macro will always be written in this window and will reside inside an item in the Project Explorer.
To open a Code Window double click on the desired item in the Project Explorer window.
The Toolbar provides some essential options for the project (buttons such as Undo and Save). There are also on this bar buttons to execute the code (such as Run Macro and Reset) and help for creating codes (such as Find and Paste).
It is possible to edit the Toolbar. You may add for example the edit buttons tab, which allow commenting on a block of text (View $\rightarrow$ Toolbars $\rightarrow$ Edit).
The Menu bar lists the features of the VBE.
When you are having trouble finding some functionality in the Toolbar, you may choose to browse the menus in the Menu bar.
The Immediate Window is mainly used to check variable values and perform tests. It allows:
While debugging, just place a question mark (?) before a variable in this window to see its value.
You may execute a line of code in the Immediate Window by pressing Enter.
It is a window that allows you to manipulate the features of an object. It is especially useful for configuring ActiveX Controls.
You can customize the appearance of some spreadsheet elements (such as buttons and headings) in this window.
This window displays automatically when, in breakpoint mode, all the variables have been processed, such as their current values and their respective data types.
A Module is a place for you to store codes.
In general, macros are written in modules.
Further ahead we will see cases where the code is inserted into other Project Explorer items.
To create a Module (with VBE open):
Try to use the modules when writing your macros.
SuperExcelVBA.com is learning website. Examples might be simplified to improve reading and basic understanding. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. All Rights Reserved.
Excel ® is a registered trademark of the Microsoft Corporation.
© 2019 SuperExcelVBA | ABOUT
Thank you for contributing. A message was sent reporting your comment.