Excel & VBA

17 Feb 2018

The Visual Basic Editor

Posted By

The Visual Basic Editor

Before a Visual Basic for Applications (VBA) program can be written, you need to know where to put it. Within Microsoft Excel, VBA code is written in the Visual Basic Editor (VBE). This is accessible on the main Excel Ribbon Menu, or by hitting ALT+F11 on the keyboard.

Navigating to the Visual Basic Editor

Figure 1: Navigating to the Visual Basic Editor

The VBE may be a screen you’re unfamiliar with. The user interface is relatively simple and is split into 5 key sections:

Visual Basic Editor Layout

Figure 2: Visual Basic Editor Layout

  1. Menu Bar: Similar to the menus you’re used to in most windows applications, it allows access to all the commands available within the Visual Basic Editor.
  2. Toolbar: Allows quick access to ta number of regularly used commands.
  3. Project Explorer: All VBA programs form part of a larger project which encompasses the parent Excel workbook, worksheets, charts etc. together with code modules which contain the actual VBA programs. The Project Explorer is a visual overview of the structure of the project, allowing quick access to the objects and modules within it.
  4. Properties Window: Some objects and modules have properties or attributes. Each property has an associated value, which can be manipulated using the Properties Window.
  5. Main Workspace: The principle work area. All files and modules opened in the Visual Basic Editor appear in the Main Workspace.

Code Modules

All VBA programs are placed in code modules, which are interactive windows in which your code can be typed, copied and pasted. Each project can have as many modules as required. Consequently, more complex projects are broken down into many modules; whereas small projects can often be stored in a single module.

There are several types of code modules including standard, userform and class modules. In general, and especially at an introductory level, all VBA code will be place in a standard code module, often just referred to as ‘Modules’. We’ll get into the other types, and the functionality they offer, in a later lesson.

Adding a New Standard Code Module

Adding a new module is easy, just right click anywhere within the Project Explorer (see Figure 1 above), then select Insert > Module. This will create, and automatically open in the Main Workspace.

Insert New Module

Figure 3: Insert New Module

Congratulations! You just created your ‘Module1’ you first step into the depths of VBA. You should have seen a new blank window pop up, this is where you’ll soon be writing your own VBA code.

If you would like more information on the Visual Basic Editor, please visit MSDN:


3 Responses

  1. Pingback : ExcelWTF (Learn) VBA Procedures, Subroutines and Functions - ExcelWTF (Learn)

  2. Pingback : ExcelWTF (Learn) What are Variables? - ExcelWTF (Learn)

Leave a Reply