Excel VBA Editor
VBA Editor is a place where we write VBA code and create macros. Whatever the code we write will be in the background to the excel file with which it is linked and once we run the code every process will happen in the background and what we see is the output in excel file. We always need to activate VBA Editor when we want to see that. And there are many ways to do it. We will be seeing the process of using VBA Editor for MS Excel only. But for all other Microsoft products has the same ways of using Visual Basic Editor.
How to Open VBA Editor in Excel VBA?
We will learn different examples of Open Visual Basic Editor in Excel.
If we have selected the option for Developer ribbon from the File menu option, then we would probably see the Developer menu tab in the Menu bar at the top. To access VBA Editor, go to the Developer tab and select Visual Basic option under Code section as shown below.
Once we click on the above-highlighted menu, this will take us to Visual Basic Editor Window’s home page.
There is always a shortcut key to access a function or command which we do by the simple manual process of clicking. So VBA Editor has also a shortcut key. For accessing VBA Editor Press Alt + F11 keys together. This simple shortcut is easy to remember and quite frequently used when we work regularly on VBA Coding.
This shortcut key can be used both ways, to get into VBA Editor Window and from the VBA Editor window to Excel.
There is another way to access VBA Editor. For also quite a direct method to get into editor mode. For this, click right on the Excel sheet tab and select View Code option as shown below.
Explanation of VBA Editor
We have seen how VBA Editor can be accessed. Above are the steps and methods of going into VBA Editor. Suppose we are in the VBA Editor Window following any of the methods which are shown and explained above. We will see the home window of VBA Editor. There are different sections in VBA Editor Window itself.
1. Menu Bar
Like every other Microsoft product, there is a Menu bar in VBA also. The menu in VBA consists of different menu options. Common menu options are File, Edit, View, Insert, Tool and Help. These options are mostly available in many and all the menu bars.
The other options which only be there in VBA are Debug, Run, Add-Ins, and Windows.
All the menu options in the Menu bar have different sub-options and functions which are used to process the subsequent work.
Just below the Menu bar, Toolbar is available. The Toolbar is that section in VBA, where we can find some shortcut buttons which are there in some of the menu bars. Toolbar commonly has Save, View Excel Sheet, Insert User Form, Cut, Copy, Run, Pause and Stop Code, etc.
3. VBA Project Window
Project Window is the place in VBA where we can find all the sheets, module and project names. This window is most of the time located on the left side of the VBA window.
4. Properties Window
Properties window is mostly located below the Project window. We can move this window as per our needs and requirement. This window shows all the properties of selected Workbook, Worksheet or Module. As here we have selected Workbook so that properties of that are getting reflected.
But sometimes we will not be able to find it. To access, this go to View menu tab and select Properties Window (Or press F4) as shown below.
Module is the place where we mostly write the code. Although we can write the code in Sheet, UserForm as well. Benefit or writing the code in Module is that it is easy to execute and we can use it anywhere we want to.
A module can be inserted from the Insert menu tab as shown below.
Once we click on it, we will be able to locate the newly added Module in VBA Project Window with a white blank screen where we can write our code as shown below.
How to Use Excel VBA Editor?
Visual Basic Editor is the place in any MS Office tool where all the coding related to any automation is done. We can use it in many ways.
- We can use it for creating a macro.
- We can create a macro by writing code in VBA Module or Sheet or else we can record a macro as well.
- We can also use the written code to link different multiple files of various extensions.
Pros of Excel VBA Editor
- Code written in VBA Editor can directly be implemented in related and linked applications of Microsoft Office.
- This is the easiest way to write and apply any code as compared with other languages in Java, PHP, and Python.
Things to Remember
- It does not allow us to save the code in any format. For this saving or retaining the code in MS Office applications, we need to save that file that has the code in Macro-Enabled files.
- Play with different options and buttons available in VBA Editor Window to get familiar with their functions and applications.
- Coding for creating macro can be done in Module, Sheet and User Form.
- We can apply the written code in Module or Sheet to any buttons which can be created by options available in Developer ribbon from Control
This is a guide to VBA Editor. Here we discuss how to open Excel Visual Basic Editor and also how to use Visual Basic Editor including Menu Bar, Tool Bar, Project window and Properties window with description. You can also go through our other suggested articles –