Locked lesson.
About this lesson
Meet the Visual Basic Editor (VBE) - your coding studio.
Exercise files
Download this lesson’s exercise file.
Navigating the Visual Basic Editor.xlsm25.5 KB
Quick reference
Navigating the Visual Basic Editor
An introduction to the Visual Basic Editor (VBE) coding studio
When to use
To create or edit macros and other VBA code
Instructions
Open the Visual Basic Editor via either of the following two methods:
- Go to the Developer tab --> Visual Basic, or
- Press Alt + F11 from Excel
The Visual Basic Editor Windows
The utility windows are all accessible via the VBE's View menu. The most commonly used windows are:
- Project Explorer (shortcut key CTRL + R)
- Properties Window (shortcut key F4)
- Immediate Window (shortcut key CTRL + G)
- Locals Window (no shortcut key)
- Watch Window (no shortcut key)
Opening code panes
- Once you have the Project Explorer showing, simply double click on the object or module you want to work on.
- Note that more than one object or module can be open in the Coding Pane at a time.
Useful Toolbars
To launch a toolbar, go to View --> Toolbars and select the toolbar from the drop-down menu
The toolbars most commonly used are:
- Debug
- Edit
Hints & tips
- If a window is closed, open it by clicking on View and selecting the window from the drop-down menu or by using the shortcut key (if available).
- To move a window, left click the window and drag it to the general area you want it to be located until it “snaps” into place.
- To resize a window, hover over the side you want to expand until you see the double arrow. Left click and drag the side over or down until the window is the size you want.
- Each toolbar can be docked in the main toolbar area at the top of the screen. Just click and drag it up until it “snaps” into place.
- 00:05 So far, we are working with macros.
- 00:08 We've prerecorded steps that are available for us to replay whenever we want and
- 00:12 everything's all good, right?
- 00:15 The challenge is, is that we want to move ourselves to working with,
- 00:18 not just macros but with VBA.
- 00:19 The entire language itself.
- 00:21 And we wanna see what we can actually do with it.
- 00:24 In order to do that we need to get a little bit familiar with
- 00:27 the environment that we're gonna use to preserve programming.
- 00:30 This is the Visual Basic Editor or the VBE as we know it.
- 00:35 And you can find that on the Developer tab by clicking Visual Basic.
- 00:40 And that will launch you into a new window that looks like this.
- 00:43 I'm gonna show you another way to get in here as well.
- 00:46 I'm just gonna go and close this for right now.
- 00:48 There's a keyboard shortcut and the more you program,
- 00:50 the more you'll find that this becomes one of your go to keyboard shortcuts.
- 00:53 It's Alt+F11.
- 00:55 And Alt+F11, even if the developer tab is not available,
- 00:58 will launch you into the Visual Basic Editor, the VBE.
- 01:03 Now, this is a code studio that looks the same in every version of Excel,
- 01:07 from Excel 5 all the way through to Excel 2016 today.
- 01:11 There's been no changes to it whatsoever.
- 01:13 This is why I'm actually very comfortable teaching this course in Excel 2016 no
- 01:16 matter which version of Excel you absolutely have.
- 01:19 You'll notice that it's got the old classic toolbars, not ribbons or
- 01:22 anything like that.
- 01:23 And it's got a multi document interface, which is what we're used to,
- 01:27 where all of our documents fit into one particular piece.
- 01:30 They don't all have their own individual container like we see in
- 01:33 Excel 2013 and 16.
- 01:33 Now, some key parts that I want to make you familiar with when you're in here.
- 01:39 On the left hand side we have a navigation tree.
- 01:42 And you'll notice that the workbook I've opened is called Navigation.xlsm.
- 01:47 And you'll see that we have a few different things in here.
- 01:49 We've got a Microsoft Excel Objects container that has the different
- 01:52 worksheets, as well as something for ThisWorkbook.
- 01:54 We see Modules with Module1.
- 01:57 This is what we actually call the Project Explorer and
- 02:01 if you ever lose it, go and click and close all these guys away here.
- 02:05 If you ever lose it, you can find it on the view menu under Project Explorer or
- 02:10 by pressing Ctrl+R, and that will bring it back up.
- 02:14 Another window that's useful in here is the Properties Window.
- 02:17 The Properties Window gives us the Properties of the selected objects.
- 02:21 So in this case here, we can see that it's Sheet1.
- 02:23 If I were to go and click on Module1,
- 02:25 it will tell me the properties of Module1 in ThisWorkbook.
- 02:28 It gives me a bunch of different properties there as well.
- 02:30 So this is something that can be useful.
- 02:32 Again, you can dismiss it.
- 02:35 There we go.
- 02:35 We can bring it back either by the menu or pressing F4 and
- 02:38 that will bring this guy back.
- 02:40 All right, cool.
- 02:41 So we've got our Properties Window.
- 02:42 I usually like to keep mine tucked just down in the bottom over here somewhere.
- 02:46 It gives me enough room to work with that I can play around with the stuff
- 02:49 that's up top and everything works well there.
- 02:52 Couple other windows that you may want available to you.
- 02:57 On the View tab we have Ctrl+G, gives us the Immediate Window.
- 03:01 I like to dock that down the bottom here where it shows up by default.
- 03:05 I'll get more into explaining what these do when we get into advanced debugging
- 03:08 a little bit later on.
- 03:09 But it's handy to have around.
- 03:11 I'm also gonna go into my View tab here, and
- 03:13 I'm gonna show the Locals Window and that comes up in this area.
- 03:17 Now I'm not really a huge fan of where this is docked,
- 03:20 because I like the Window for Locals a little bit taller.
- 03:23 So I'm gonna go and left click and drag this guy off.
- 03:25 Get him out into the main area here.
- 03:27 And then I'm gonna drag him onto the right side of the screen until we see it snap
- 03:31 like that.
- 03:31 And then we go, I've got a Locals Window.
- 03:34 It's empty right now, but that's okay.
- 03:37 There's one more window that you may want as well, which is called the Watch Window.
- 03:41 This one docks down in, beside Immediate, I'm okay with that.
- 03:45 Although I would generally make the immediate window just a little bit longer.
- 03:48 So this is the main frame work for what we end up working with.
- 03:52 The key part that we wanna recognize is in the middle is where our real big
- 03:55 canvas is.
- 03:56 And if I go double click on Module1 it's gonna open that up in the middle here and
- 04:00 this actually shows me the code that I'm working with.
- 04:03 And I've just maximized this.
- 04:04 I could go back if I wanted to and
- 04:06 click on this little guy here which will restore it and bring it down as well.
- 04:10 What's interesting about this again, this is a multi document interface.
- 04:13 So if I double click on ThisWorkbook it will open up the code pane for
- 04:16 ThisWorkbook.
- 04:16 And you can see that we've got a couple of different windows here.
- 04:19 But if I were to maximize Module1, it will take over the entire thing.
- 04:23 So, I can't see the other window.
- 04:26 If I go and click on this one again, I can.
- 04:28 I could flip over at him and maximize him.
- 04:30 Or I could click the little x, make him go away and
- 04:34 stick around in this particular place.
- 04:35 Okay, so this is some of the key stuff that we wanna be aware of.
- 04:39 There's also a couple of other things that you'll probably want to have as well.
- 04:42 And these are a couple of Toolbars.
- 04:44 We have a Debug toolbar, so I'm just gonna show that.
- 04:48 And I'm gonna bring him up here and snap him up into the top of my ribbon.
- 04:52 And I'm gonna go, actually not ribbon, Toolbar.
- 04:55 And we'll say, let's grab the Edit window or Edit form as well.
- 04:59 This gives us some more commands that we'll use when we're playing around with
- 05:01 our debugging, so I'll stab it in there.
- 05:02 You can of course, set toolbars you can pull them off and
- 05:04 have them where you like them.
- 05:06 But I like to keep all mine up at the top, give myself a little bit more space.
- 05:10 This is the Visual Basic Editor.
- 05:11 This is the environment that we're gonna use when we start programming.
Lesson notes are only available for subscribers.