Visual Basic Editor Tutorial for Excel – How to use the VBE?

The Excel Visual Basic Editor is also sometimes referred to as the VBA Project window. The Visual Basic Editor (VBE) is a simple developer environment available in Excel, Access, PowerPoint, Word and all other MS Office applications. It allows you to code simple Visual Basic for Applications macros. If you are new to VBA checkout my VBA Tutorial.

Today we will learn the basics as well as some tips and tricks on how to master the VBE (Visual Basic Editor).

How to open the Visual Basic Editor?

The Developer tab in the Excel ribbon is required to work with Excel VBA. Apart from enabling you to access your VBA Project, it also contains other useful features and shortcuts which we will dive into later e.g. Macro recording, Form Controls (buttons, checkboxes etc.).

Did you know… you can use the ALT+F11 keyboard shortcut to open the Visual Basic Editor (VBE) window?

Add the Developer tab to your Excel ribbon

To open the options window go to:
File->Options->Customize Ribbon
Next select the Developer tab to add it to the Excel ribbon as shown below:

Excel VBA Tutorial: Select the

Click Ok. You should now see a new tab in your Excel ribbon called Developer as shown below:

Excel VBA Tutorial: The Developer tab in the Excel ribbon

Click the Visual Basic button on the Developer ribbon

Click the button as shown below:

Excel VBA Tutorial: Click the Visual Basic button

This will open the Visual Basic editor as shown below:

Excel VBA Tutorial: The VBA editor window

The Visual Basic Editor (VBE)

The VBE Project Window

The VBE Project Windows allows you to manage your VBA Project objects such as VBA Modules, Classes and Forms.
Excel Visual Basic Editor Overview

The VBE Code Window

THe VBE Code Window allows you to edit your VBA code – by selecting a VBA Module, Classes or Form in the VBE Project Window (see above).
Excel VBE Code Window Overview

VBE Tips and Tricks

Now for some tips and tricks.

Tip 1: Open the VBE (Visual Basic Editor) with VBA

May sound weird but it is actually a pretty neat trick. The following VBA code snippet can be set as a Button event to open the VBA Project Window:

Sub OpenVBE_Click()
    Application.VBE.MainWindow.Visible = True
End Sub

Below a quick gallery tutorial of How to setup a button to open the VBE from an Excel Worksheet:

Tip 2: Open VBE Window on selected Macro

If opening the VBE (Visual Basic Editor) Window on the click of a Button is no specific enough.. why not a Macro that allows you to open the Visual Basic Project Window to not only open but also open the VBE on a specific Macro of your choice! The VBA code snippet below does precisely that.

The VBA code snippet will open the VBE Window on the “Test” VBA Macro:

'Module 1
------
Sub OpenSub_Click()
    Application.Goto "Test"
End Sub

'Module 2
------
Sub Test()
    '...
End Sub

Summary

The VBE (Visual Basic Editor) is where all the magic happens. Got any useful VBE tips or tricks of your own? Share them in the comments below!