Please note javascript is required for full website functionality.


VBA Blogs: Going Through the Visual Basics – Part 5

7 September 2018

We thought we’d run an elementary series going through the rudiments of Visual Basic for Applications (VBA) as a springboard for newer users. This blog looks at the VBA Editor.

Using the ‘View Macros’ option is one way to get to the VBA Editor. However, it is also accessible from Excel via the ‘Developer’ tab in the Ribbon. Under the ‘Code’ category on the ‘Developer’ tab, clicking on the ‘Visual Basic’ button will take us directly into the VBA Editor:

Alternatively, ALT + F11 is the keyboard shortcut to enter the Microsoft Visual Basic for Applications editor (known as the “VBA Editor”).

Let’s review the Visual Basic Editor and familiarise ourselves with the different components.

Many of these terms are self-explanatory but let me go through some of them.

  • The Code Window is where procedures appear, i.e. macros that have been recorded and stored are also displayed here.  The code window is also where we can write code for our macros
  • The Procedure List is visible at the top-right of the Code Window.  From this list, navigation to any procedure in the active module is quick and easy.  Also notice the view options at the bottom of the screen.  When we have several macros in a module, it can be helpful to view them one at a time
  • Full Module View allows us to switch between viewing the ‘Full Module view’ and single procedure view with just a click of a button
  • The Immediate Window is used to debug and evaluate expressions, execute statements, print variable values etc.  It allows us to enter expressions to be evaluated or executed by the development language during debugging
  • Project Explorer is where we see the list of all VBA projects that are currently open or loaded.  All open documents, as well as open or loaded document templates, appear here, regardless of whether they contain macros or not.  They can be easily collapsed or expanded to view the modules and objects that it contains
  • For modules, the Properties Window is generally used only to edit the module name.  Module naming rules are the same as macro naming rules – no spaces or special characters and the name must begin with a letter.  However, for some object types (such as UserForms), the Properties Window becomes extremely important because it's populated with many settings that we can edit directly in that window, like the height and width of a UserForm or the value to display on a form control.