The VBA Editor - Overview
- 04:37
Understand the main features of the VBA Editor
Downloads
No associated resources to download.
Glossary
VBA Code VBA Project VBA PropertiesTranscript
So, to get into the VBA editor and start looking at the code that was created when we recorded our macros, so that we can potentially go and edit those macros, there are a couple of ways to go. Either we can go in via the developer ribbon, so it would be Alt+L, and then to get into the Visual Basic Editor, it's V, so Alt+L+V, or you can go to the Macros dialogue box, so that would be Alt+F8, and then we would go to pick the macro that we wanted to go and edit, and then we'd choose Edit from the menu item on the right-hand side. So, either of those ways gets us into the editor, and we can also use the keyboard shortcut Alt+F11 to go straight into the editor as well, which is what I've just done there.
So, when you go into the Visual Basic Editor, the first thing to say, it's a separate application. So, Excel is still running as a separate application, and if we use Alt and Tab to flick to Excel, then we can still then go Alt and Tab back again to come back into the editor. So, we can have two applications, Excel and the Visual Basic Editor, running at the same time. If I want to, I can just close the Visual Basic editor, and we're back into Excel. Alt+Tab+11 to go back in again. If I close Excel, the Visual Basic editor will also close as well. So, you can have Excel open and not the editor, and you can have both of them open, but you can't have the editor open without Excel. So, there is a dependency, but they are two separate applications to all intents and purposes.
So, the next thing is to say there are three main areas, or three main windows, that we'll be working with when we're working with the editor. Over on the left-hand side, we've got two, one above the other. We've got the project window, then the properties underneath it, and then over on the right-hand side is where our code will appear, so that's the code window, so project, properties, and the code. If for some reason the project window isn't open, then you'll see something like this, and up on the toolbar, you'll see there are two icons right next to each other, project and then properties. So, you can close them both and you can use the buttons to bring them both back again. You can tile them to your needs and change the size of the windows just by dragging the connecting bar.
So, those are the three main windows. The properties area holds properties about the thing that we have selected in the Explorer. Now, we don't use the properties window for very much, but we will use it for renaming modules. We'll talk about that a bit later. What we do need to know then is, how do we use the Project Explorer to go and bring up the relevant code window for that code that we just created? So, the more macros we've recorded. Well, for every single workbook that I have open, you'll find, in bold, a VBA project and then the name of the workbook. So, you'll see here "VBAProject (Excel VBA and Macros), that's the name of my workbook, and underneath that, you'll find there are two folders. One's called "Microsoft Excel Objects." We don't need to worry about that, but you will also find there's one called "Modules," and in there, there'll be one or more modules with the recorded macros that we created, and all you need to do to bring up the code and edit that, or to look at the code, is just to double-click on the module. If the window doesn't appear maximized over on the right-hand side, obviously, all you need to do is just hit the maximized window, and here are the macros we recorded. There's one final thing to say about the macros that we recorded. By default, we're in a tile view, so the macros appear one above the other. So, within the same module, we can have multiple macros. We can switch the view though so that we are in single view. So, you can either use the dropdown list at the top here or you can use the keyboard true gap, which is Control and up or down arrow key, to switch between your macros. So, that's a little bit about the editor and how we move around and some of the terminology.