Beginning VBA: The Visual Basic Editor

The Visual Basic Editor (VBE) is a separate program, but inextricably linked to Excel. The VBA code that you write is written in the VBE, so it’s kind of important to the process.

There are a few ways to get into the VBE, but for now get used to using Alt-F11. That’s the shortcut of Tools>Macros>Visual Basic Editor and it simply opens the VBE.

The VBE contains many useful windows and toolbars. Here’s what mine VBE looks like:

VBE1.gif

I show the Standard, Edit, and Debug toolbars. I don’t know if I actually use those toolbars, but they don’t take up much real estate so I keep them visible.

On the left is the Project Explorer. If the Project Explorer isn’t visible in your VBE, you can make it so by going to the View menu. It lists all the workbooks that you have open (whether you know you have them open or not.) I basically have Book1 open, but there are four “projects” in the window. (Project is what the VBE calls a workbook.) The other three are add-ins that I’ve installed.

You use the Project Explorer to create or open modules that that you want to work on.

At the bottom of the screen is the Immediate Window. You can type VBA statements into the Immediate Window to see what happens when they are executed. You can also write stuff to the Immediate Window from within your programs by using the Debug.Print statement. I keep the IW open all the time, because it’s so darn useful. If it’s not open on your machine, you guessed it, go to the View menu.

The big blank area in the middle of the screen is where the code window goes. I don’t have a code window open in the picture above, but if I did, that’s where it would be. The code window is where you actually write or edit the VBA code.

Tomorrow: Writing your first procedure (aka macro).


Posting code? Use <pre> tags for VBA and <code> tags for inline.

Leave a Reply

Your email address will not be published.