×

Introduction to Visual Basic Editor Window

How to enable the Developer Ribbon Tab?

In order to work with VBA, users need to make a small change in Excel to display a new tab (Developer) at the top of the screen. Microsoft Excel does not display the Developer ribbon tab by default. So, getting Excel to display the developer tab, follow these steps.

Method 1

  • File -> Options -> Excel Options -> Customize Ribbon -> Check Developer -> Click OK
Introduction to Visual Basic Editor Window

OR

Method 2

  • Click anywhere on the Ribbon and choose to Customize the Ribbon
  • Look at the right side of the Customize the Ribbon dialog box
  • Checkmark next to Developer
  • Click OK

Developer Ribbon Tab

The Developer tab contains the most powerful tools in Excel that allow you to create and access macros, to develop and customize Excel. Developer Ribbon Tab has further three sections which are explained below:

  1. Code: This section is used to open VBA Editor, view, record, and manage your macro security option.
  2. Add-ins: This option allows the user to manage the Add-ins, Excel Add-ins and COM Add-ins
  3. Controls: This section enables the user to view the VBA code, set properties, activate the form, and insert ActiveX controls.
  4. XML: This option manages the importing/ exporting Data and XML extension packs options.
Introduction to Visual Basic Editor Window 1

What is Visual Basic Editor?

Visual Basic Editor (VBE) is an environment which is used to write the VBA codes. You can’t run VBE separately, and Excel must be open for VBE to run. It is used to create, modify, debug, and maintain the VBA (Visual Basic for Applications) procedures, codes, and modules in Excel. The Visual Basic Editor (VBE) is contained in the Microsoft Excel workbook.

Introduction to Visual Basic Editor Window 2

How to activate VBE ?

There are two procedures to activate the Visual Basic Editor window in Excel.

Option 1

Press ALT + F11

Option 2

Choose Developer -> Code Visual Basic

Components of VBE

The components of the VBE are as follows:

Menu Bar: VBE has a Menu Bar which has menus like File, Edit, View, Insert, … and other Toolbars, like Standard, Debug, Edit & UserForm Toolbars where you can add Commands like Save, Print, Delete, Undo, Redo,

Code Window: This is the area in VBE in which you write the codes and records the macros. On the top right is the Procedure list with which you can quickly move to another procedure in the active module. At the bottom of the code window, you can adjust between the Procedure view, which displays a single procedure in the active module, and the Full Module view, which is the default view and displays all procedures in the active module.

Project Explorer: It displays the list of all existing projects. It represents the modules and sheets in a hierarchical view wherein you can fail to hide or expand to view the objects, user forms, and modules included in a project. The project contains Object Folders, Forms folder, Modules Folder, and Class Folder. The object folder is the default folder and consists of a sheet object and This workbook object within it.

Properties Window: This window in VBE presents a list of properties for the selected object or variables, which can be modified here. To display the Properties Window, click on View in the Menu Bar -> select Properties Window or press the F4 button. It is used to edit the User-Form properties, controls properties, unlike TextBox, ComboBox, CommandButton, etc.

Procedure Box: Procedure box contains a list of the existing individual macros or procedures within the active module under the 'Declarations' heading.

Object Box: Object box displays 'General', which is the default object. It is used to select an object to work unlike worksheet, workbook, user form, checkbox etc.,

The Immediate Window: The Immediate Window facilitates debugging the VBA code and allows the user to check the output of an individual line of code. Hence, it provides an ease to rectify if there is an error in the code. You can type the code and then press enter to execute, which enables immediate execution of the method or procedure. To show the Immediate Window, click on View in the VBE Menu Bar and select Immediate Window, or press the shortcut keys, CTRL+G.

Introduction to Visual Basic Editor Window 3

The Locals Window: This window displays the name, value and type for all declared variables in the current procedure automatically and updates the variables' values while the code is executed and hence, is used in VBE as a debugging tool. To view the Locals Window, click on View in the VBE Menu Bar and then select Locals Window.

The Watch Window:  The Watch Window helps you to view and monitor the current value of a variable or expression, whose name, amount, type, and context are to be displayed in the Window. You need to explicitly add a variable or expression to the Watch window which you want to monitor, unlike in the Locals Window, where all the expressions and variables are displayed automatically in the current procedure. To add the variable or expression to the Watch window, select it and right-click and then click Add Watch, or select it and click Add Watch or Quick Watch on the Debug menu, or press the shortcut keys Shift+F9. To display the Watch Window, click on View in the VBE Menu Bar and then select Watch Window.

The VBE Environment

Visual basic environment or VBE is an Integrated Development Environment (IDE) developed by Microsoft. It uses a Graphical user interface with a basic programming language and is the first software to provide a graphical programming environment for developing a user interface module or applications.

In VBE, a considerable volume of code gets swapped by the controls, where the user must drag and drop to add any control in the interface. This environment does not have any object-oriented programming language concept.

Various attributes and event handling are coupled with the controls and default values are assigned to the controls when it is created, and it is possible to change the default values. This environment primarily allows to create a windows application, additionally create executable (exe) files, ActiveX controls, and DLL files.


Related Topics

Excel VBA DateDiff Function

The DateDiff function in VBA returns a Long data value representing the number of intervals between two specified dates/times where the type of interval is supplied by the user. Syntax DateDiff (Interval, Date1, Date2, [FirstDayOfWeek], [FirstWeekOfYear]) Parameter Interval (required)...

2 minutes read.

Excel VBA Day Function

The function Day in VBA returns the day number (from 1 to 31) for the given date value. Syntax Day (Date) Parameter Date (required) – This parameter represents the date. Return This function returns the day...

1 minute read.

Excel VBA: DO WHILE….Loop

DO WHILE….Loop The “Do While” Loop is the same, unlike the FOR statement, just that it will keep on looping till the specified condition is true. It is used when we want to...

3 minutes read.

Finding Last Row or Column in Excel VBA

Finding Last Row or Column in VBA Finding the last used row, column, or cell is one very commonly used task when we write macros and VBA applications.  Like other codes...

5 minutes read.

VBA VBScript Regex Methods Regex

VBA VBScript Regex Methods Regex The VBA Regex supports 3 methods which are as follows: ExecuteReplaceText Execute The execute method is used to extract a match from the given based on the defined matching...

3 minutes read.

Excel VBA Now Function

Excel VBA Now Function: The Now function in VBA returns the current date and time.  Syntax Now () Parameter NA Return This function returns the current date and time.  Example 1 Sub NowFunction_Example1() 'It will return...

1 minute read.

Excel VBA User-Defined Functions

User-Defined Functions One of the advantages of VBA is that you can create your own functions using macros. These functions can be called and used as other functions in excel and use them. You can...

3 minutes read.

Excel VBA Error Function

VBA Error Function: The Error function in VBA returns the error message corresponding to a supplied error code. Syntax Error ([ErrorNumber]) Parameter ErrorNumber (optional) – This parameter represents the required error number. By default, the...

1 minute read.

Excel VBA Minute Function

The Minute function in VBA returns the minute component for the specified time. Syntax Minute (Time) Parameter Time (required) – This parameter represents the time. Return This function returns the minute component for the specified time. Example 1 Sub MinteFunction_Example1() ...

1 minute read.

Excel VBA Time Function

Excel VBA Time Function: The Time function in VBA returns the current time. Syntax Time () Parameter NA Return This function returns the current time.  Example 1 Sub TimeFunction_Example1() ' returns the current time Dim time_val...

1 minute read.

Excel VBA Left Function

VBA Left Function: The Left function in VBA returns a substring from the start of the specified string. Syntax Left (Str, Length) Parameter Str (required) – This parameter represents the string that you want to extract...

1 minute read.

Excel VBA InputBox

Input Box The InputBox function in VBA is used to prompt the users to enter values. The user can click either the OK button or can choose the CANCEL button. If the user clicks...

3 minutes read.

VBA Type Mismatch Error

What is a Type Mismatch Error? VBA Type Mismatch Error is a run time error in excel, which often occurs when the data types contained in a VBA code are not matched...

3 minutes read.

CodeIgniter Architecture

Here we will understand the architecture and working of the CodeIgniter application, which helps you to elaborate all steps in simple ways. As the above image represents that whenever a request comes from the...

2 minutes read.

VBA Charts Basic Operations

VBA Charts- Basic Operations The Chart Object in Excel VBA represents the collection of all the charts sheet present in a workbook. A chart can be either an embedded chart or a separate chart sheet. The...

6 minutes read.

Excel VBA Conditional Statement

Conditional Statement in VBA Excel Conditional Statements in Excel VBA are one of the most powerful and useful features in programming, this will give you to perform comparisons to decide or...

2 minutes read.

Excel VBA FormatDateTime Function

VBA FormatDateTime Function: The FormatDateTime function in VBA returns the result as a string after applying a date and/or time format to the supplied expression. Syntax FormatDateTime (Expression, [NamedFormat]) Parameter Expression (specified) – This parameter...

2 minutes read.

Excel VBA IsObject Function

VBA IsObject Function: The IsObject function in VBA returns a Boolean value showing whether the specified variable represents an Object variable type or not. Syntax IsObject (Expression) Parameter Expression (required)- This parameter represents the...

1 minute read.

UserForm and its Properties Excel VBA

UserForm and its Properties Userform has certain properties that can be viewed as category wise (based on appearance, behavior, font) or in an alphabetic manner. The property window is used to set or...

11 minutes read.

Excel VBA DateValue Function

The DateValue function in VBA returns a VBA Date from the given String representation of a date wherein the time information is ignored. It is unable to interpret dates that include the...

1 minute read.