VisualBasic Editor in Excel
1. VisualBasic Editor – Introduction
The VisualBasic editor is the most importatnt tool we will use in our VBA Course. To be able to fully use VBA on your computer, you should start with:
- Unlock the Developer tab in your Excel ribbon
- Enable macros support
2. How to enable the Developer tab in Excel ribbon?
The Developer tab in Excel is disabled by default. This card allows us programming in Excel VBA. To unlock the tab first go to File in the upper left corner of the screen. Then go to Options> Customize ribbon. According to the screen below, check the Developer checkbox. After that you will see Developer Card in your Excel ribbon.
3. How to enable macros in Excel VBA?
Macro operations, are programs running under Excel. You can activate macros in a similar way like you activated Developer tab. First go to File, then Options > Trust Center> Trust Center Settings. In this menu, select the Macro Settings button. Choose the most advanced option, named “Enable all macros”. Now macros in your Excel can already run without any restrictions. Remember, that by selecting this option you reduce the security of Excel applications. You shouldn’t launching programs that are not save.
4. VisualBasic Editor Elements
On the developer tab, click on VisualBasic icon. Here you will write your Excel VBA programs. You can also open Excel VB Editor with the Alt + F11 key combination. The VisualBasic editor can be close by returning to Excel worksheets using Alt + Q.
4.1 Project Project window
In the Project window you have access to the main editor objects. By right-clicking on Microsoft Excel Object, you can insert new object into project. It can be a module, a userform, or a class module. At the beginning you will use modules. Module is the basic element in which you will write your programs. You can learn more about the UserForms at the end of VBA course. You can also access the Project window using the CTRL + R key combination.
4.2 Properties window
With Properties window you can access the properties of each of your programming objects. For example, this can be the properties of module, UserForm, worksheet, or the workbook. In the Properties window you can set all the properties of the object, starting with its name and label, and ending with color settings, formatting, default values, etc. You can go to the Properties window by pressing the F4 key.
4.3 Program control buttons
The application action buttons are in the upper bar of the editor. They are used to start, pause and stop running your programs.
4.4 Code editing window – Code
In this window, you will enter the code of your programs. The most important elements in the Code window are the Object selection box (left) and the procedure declaration box (right). For example, your programs can be started with a button click. In this case the object will be a button, and the procedure will run after double click on the button. We use the keyboard shortcut F7 to enter the Code window.