The first step to working with VBA in excel is familiarized with the Visual Basic Editor also called the VBA Editor, VB Editor or VBE Editor.
Visual Basic Editor is a separate application. It is a part of Excel and opens whenever you open an Excel workbook. By default, it's hidden, and you have to activate to access it.
Visual Basic for Applications Editor is a very powerful tool. It is an interface for creating scripts.
VBA Editor is the place where you keep the VBA code.
There are multiple ways to get the code in the VBA Editor, such as:
Access the VBA Editor
There are various ways to access or open the Visual Basic Editor in VBA, such as:
1. Using a Keyboard Shortcut
Let's see how to access the VBA Editor using a keyboard shortcut such as:
This is the easiest way to access the VBA Editor to use the keyboard shortcut, i.e. hold the Alt key and press the F11 key (Alt + F11).
It opens a separate window for the Visual Basic for Application Editor.
This shortcut works as a toggle. Therefore when you use it again, it will take you back to the Excel application.
NOTE: For the Mac version the shortcut key is Opt + F11 or Fn + Opt + F11.
2. Using the Worksheet Tab
Let's see how to access the VBA Editor using the worksheet tab step by step, such as:
This is the less used method to open the Visual Basic for Application Editor.
Step 1: Go to the Worksheet tab.
Step 2: Right-click on the tab.
Step 3: Then, select the View Code option.
Step 4: It will open the VBA Editor and also open the code window to that worksheet object.
This is very useful when you want to write code works only for a specific worksheet. This is usually happening with worksheet events.
3. Using the Developer Tab
Let's see how to access a VBA editor step by step, such as:
Step 1: First go to Excel window.
Step 2: Click on the Options button.
Step 3: Click on the Customize Ribbon button.
Step 4: Select the Developer checkbox, as shown in the below screenshot.
Step 5: Then click on the OK button.
Step 6: Now, you will be able to see the Developer tab in the Ribbon.
Step 7: Select the Visual Basic option or press Alt+F11 shortcut key.
Step 8: It will open a VBA window shown in the below screenshot.