Excel Vba Guide: Vbe (Visual Basic Editor) Excel #02

Table of contents [Show]
Excel VBA Guide: VBE (Visual Basic Editor)


In the previous tutorial we have learned about the meaning of Macros and VBA . Then we have also prepared several things that are needed to start learning this Excel Macro and VBA. In addition, we have also succeeded in writing a simple VBA Macro code that produces a message box or message box.

After studying the basic VBA tutorial, what is the first question that comes to your mind?

Of course, there will be many questions that vary according to your previous level of knowledge about Excel VBA. However, it is very rare for me to find a question that touches on what a VBE (Visual Basic Editor) actually is and how each part of the VBE functions.

Even though I think this is one of the most important things for you to master the first time, as it is important for you to know the user interface in Microsoft Excel , so that by knowing the functions of each of these parts in the future you will be more effective at working with Macros or VBA Excel and follow the following guidelines.

Therefore, in this VBA Excel basic guide series, I will invite you to learn more deeply about the Visual Basic Editor or more familiarly what we call VBE.

Understanding Visual Basic Editor (VBE)

What is the Visual Basic Editor?

The Visual Basic Editor , also known as the VB Editor or VBE , is an IDE or Integrated Development Environment . Actually VBE is a separate application from Excel. Although in practice to open VBE Excel you have to open the Office Excel application first.

Visual Basic Editor is a tool (tool) programming workspace is used to create or write, modify and perform maintenance on the procedures and VBA module in Excel.

You don't need to confuse yourself with the two explanations above, because basically the meaning is more or less the same that VBE serves as a place to write and edit VBA code.

How to Open VB Editor

How do I open the VB Editor or VBE?

As explained in the previous tutorial , there are at least 3 ways to create a VB Editor in Excel. Namely:

1. In the Developer TAB -- Code Group -- select the Visual Basic menu . 

How to open Visual Basic Editor Excel



2. Right-click the name of a sheet in the sheets tab and select View Code

How to open VBE Excel


3. The last and easiest way is to use Shortcut .Alt + F11

Visual Basic Editor(VBE) Parts

What are the parts of a VBE display?

The VBE window is divided into at least 5 main sections:

  1. Menu Bar
  2. Toolbar
  3. Project Window or Project Explorer
  4. Properties Window
  5. Programming Window / Code Window / Module Window

Excel VBE(Visual Basic Editor) Parts


Menu Bar

If you are used to using a computer, I think you are familiar with this display model, which basically has the same function as computer applications in general.

The menu bar basically contains several drop-down menus. Each drop-down menu contains commands ( command ) which can be used to interact and do things with the various components of the VB Editor.

The menus include: File, Edit, Insert, Format, Debug, Run, Tools, Addins, Window, and Helps.

In some parts of this menu is also accompanied by keyboard shortcuts that you can use to access certain commands more quickly.

VBE Menu Bar


In this section there are several options that we need to match, more of which will be discussed in the next section below.

Toolbar

The Toolbar section of VBE contains buttons, icons, menus or other similar elements that can be used when working with VBE. Each menu icon on the toolbar represents a specific command or function.

By default VBE only displays 1 type of toolbar group, namely " Standard Toolbar ". Actually there are still 3 other toolbars that you can also display, namely:

  1. Debug toolbar
  2. Edit toolbar
  3. UserForm toolbar
Excel VBE Toolbars



You can adjust the appearance of these four types of toolbars on the View--Toolbars menu .

Edit Excel VBE Toolbars



Project Window or Project Explorer

The Project Window or also known as Project Explorer is located on the left, this section shows all open workbooks including hidden ones. Each open workbook or addins will be displayed as a separate project.

VBE : Project Explorer



If the Project Window is not visible by default in VBE, use a shortcut to open it.Ctrl + R

Microsoft defines Project as " A set of modules ". A project that is seen in VBE is a collection of objects that are systematically arranged according to their object groups.

A VBAProject contains at least 1 set of object groups called " Microsoft Excel Objects " and will display other sets if they exist.

Here are some of the sets, nodes or groups of objects that are displayed in each VBA project:

1. Microsoft Excel Objects : This set will always exist in every Excel VBA project and will contain at least 2 types of objects:

  • The workbook object is referred to as " ThisWorkbook ". This object represents each excel file.
  • Worksheet objects. Each worksheet will be displayed as a separate object. If in your file there are 3 sheets then there will be 3 objects that appear for this type and will increase or decrease according to the number of sheets in each excel file
2. Modules : If you create a module it will be displayed in this section. How to add modules has also been discussed in the previous tutorial .

3. Forms : When you create a form, this set of Forms will appear. Every time you create a new form, the object will be included in this set or node.

4.Class modules : If you create a class module, it will be visible in this node.

5.References : If your project contains a specific reference it will add a References node. This section you will probably rarely see because it is very rarely used for beginners like us.

At the top of the Project Explorer there are 3 icons with the following functions:

  1. Icon View Code : To display the code stored on the related object
  2. Icon View Object : To display the shape of the related object
  3. Icon Toggle Folders : To display objects in Project Explorer in groups in certain groups or vice versa.

 

You don't have to worry too much about some of the terms that may be unfamiliar above. The most important thing in this section is that you understand how VBE displays each object in a VBA project in a structured way in the VBE Project Window section.

How to Hide Project Explorer

When focusing on writing VBA code on a particular object, there are times when you need to hide this section, the goal is to make our code look wider or wider.

There are 2 Ways to hide this section of Project Explorer or Project Window :

  1. Click the "x" icon or close button in the right corner of the Project Explorer.
  2. Right-click on any part of the Project Explorer then select the " Hide " menu .

How to Hide Project Explorer


How to Show Project Explorer

Don't panic when the Project Window or Project Explorer is missing and not visible in VBE. There are at least 3 ways to bring it back:

  1. Click or select menu View--Project Explorer
  2. On the Standard Toolbar click or select the Project Explorer icon
  3. A more efficient way is to press the shortcut Ctrl + R

How to Show Project Explorer


Properties Window

The Properties Window displays the property settings of each currently active or selected object in Project Explorer. The Properties Window function is to set the properties of each VBA object. For example, to change the name of an object to make it easier to recognize and remember.

VBE : Properties Window


For those of you who are still starting to learn VBA, it seems that this section will not really need you.

How to Hide the Properties Window

Just like in the Project Explorer section, you can also hide the Properties Window section of the VBE.

There are 2 ways to hide this section of the Properties Window:

  1. Click the "x" icon or close button in the right corner of the Properties Window.
  2. Right-click anywhere in the Properties Window and select the "Hide" menu.


How to Show Properties Window

To unhide or redisplay the missing Properties Window in the VB Editor, do the following:

  1. Click or select the View menu--Properties Window
  2. On the Standard Toolbar click or select the Properties Window icon
  3. A more efficient way is to press the shortcut F4

Code Window

Code Window also known as Programming window or Module Window is a place where we write VBA code or scripts.

In this section the VBA codes will be displayed. In this section you will also edit a VBA code or script, either add code, reduce or delete a VBA code.

By default if you open a certain object then this section will look empty.

The Code Window will display the VBA code or script for each VBA object in each of your VBA projects.

Some alternative ways to access each Code Window for each VBA object are as follows:

1. Select the object in the Project Explorer then select the View--Code menu

How to open code window 1



2. Select the object then click the View Code icon at the top of the Project Explorer. 

How to open code window 2



3. Right-click the object then select the " View Code " menu . 

How to open code window 3



4. Do Double Click on the object.
5. Display code with keyboard shortcut .Alt + F7

Which method is most efficient for you?

Immediate Window, Locals Windows and Watch Window

Apart from the windows or the main window, there are 3 other windows which are usually hidden in VBE. Namely:

  1. Immediate Window
  2. Locals Windows
  3. Watch Window

Immediate Window, Locals Windows and Watch Window



The three sections of the VBE window above will help you to debug or inspect a VBA code. Does the code that we create produce certain errors or not and so on.

For now maybe you don't really need it, but believe me in time these windows will be very useful for you.

This VBE section can also be hidden and re-displayed like any other section. As an example I will discuss the Immediate Window only. For the other two windows, the method is the same, only needs a little adjustment.

How to Hide the Immediate Window

There are 2 ways to hide the Immediate Window section in VB Editor excel:

  1. Click the "x" icon or close button in the right corner of the Immediate Window.
  2. Right-click the Immediate Window then select the "Hide" menu.


How to Show Immediate Window

To unhide or redisplay the Immediate Window, alternative ways are as follows:

  1. Click or select the View--Immediate Window menu .
  2. Use keyboard shortcuts .Ctrl + G

How to Show Immediate Window, Locals Windows and Watch Window


Setting VBE Options

After understanding some of the basic parts of the VBE display above, in this section we will explain about setting up VBE options.

Although you don't have to do it, I think it's important to match these VBE settings or options so that in the future it's easier for you to follow the VBA guidelines that we write on this blog.

Show VBE Options

You can find VBE Options on the Tools menu then select Options... .

Excel Visual Basic Editor Options



After selecting the menu, the VBE Options window that appears will show 4 tabs:

  1. Editor
  2. Format Editor
  3. General
  4. Docking

Editor TAB

This TAB is divided into 2 groups: Code Settings and Windows Settings .

TAB Editor Options VBE Excel



Code Settings

For this section I suggest you checklist everything as shown in the example image.

Auto Syntax Check
If checked, VBE will actively check every script writing so that it will be immediately known if there are errors in writing VBA code when switching lines.

Require Variable Declaration
This option determines whether VBE will automatically add an " Option Explicit " statement at the beginning of your VBA module.

If this statement is at the beginning of the VBA module, it will require you to declare variables or define (explicitly) all the variables that you use in that module.

By default this option is unchecked. For those of you who are starting to learn VBA I suggest you check this option or activate it. So that we can simultaneously learn to play with variables.

Although in practice you will face many difficulties due to the activation of this option, believe me this option will be very useful for you in the future.

Auto List Members
Automatically displays a list of members of an object, either in the form of properties, methods, or constants it has.

Auto Quick Info
Automatically displays argument information for VBA functions, properties or methods, making it easier to fill in the selected input parameters.

Auto Data Tips
Automatically displays information on the part the mouse points to when debugging while in break mode.

Auto Indent
Reflected by the name of the option, this section will indent each line of VBA code the same as the previous line indent.

Windows Settings

Drag-and-Drop Text Editing
If you enable Drag-and-Drop Text Editing, you will be able to move chunks of text or VBA code using your mouse by Drag and Drop.

Default to Full Module View
If this option is enabled, the code window will display all procedures contained in an object. If the option is turned off (unchecked), you will only be able to see 1 procedure and need to use the drop-down menu in the upper right corner of the code window to switch between procedures.

Procedure Separator
If activated, at the end of each procedure a dividing line will be displayed which will certainly help our vision to distinguish each existing procedure, especially in Full Module View mode .

Format Editor TAB

This section governs how the VBA code will be displayed or seen. I'm sure you already understand the function of each part. It's just that in this section also make sure the Margin Indicator Bar option is checked. This option is intended to provide a distance between the edge of the Code Window and the script writing area, making it easier for you to place break-points.

VBE Excel Format Options TAB Editor



There is nothing you need to set further in this section, just leave it as the default.

If there is any part of this that needs an explanation, please ask in the comments section provided below.

General tab

The General TAB in the VBE option manages some general things in several categories such as Forms, error handling and how VBA code is compiled.

TAB General Options VBE Excel



The Form Grid Settings
let you control how VBE handles UserForms.

Show ToolTips
ToolTips are descriptions or descriptions displayed by VBE to help you understand the function of a particular toolbar button. If Show ToolTips is enabled, ToolTips will appear automatically whenever you hover over a certain button.

Collapse Proj. Hides Windows
This option will make VBE hide windows related to certain projects when you close the project. Applies to project, UserForm, object or module windows.
In this section just leave it as it is by default. For those of you who are new to the Visual Basic Editor to learn VBA, the default settings in the General TAB are good enough.

Docking tab
The Docking tab is used to set the behavior of each window that is different from the VBE. If checked then VBE will place windows or related windows on the edge of the VBE window.

VBE Excel Docking Options TAB



The settings section here will affect how you will arrange windows in VBE.

With options such as the image, all windows other than the code window cannot enter the programming workspace that contains the code window.

In addition, each window also does not have a maximize or minimize control . The advantage is, the location of each window can be moved to any side of the programming workspace by Drag and Drop to any side you want. For example, if the project explorer is dragged to the right area of ​​the programming workspace, a virtual line will appear that shows the location that the project explorer can occupy.

If the drag process was dropped or released when it was above the code window, the project explorer will float above the code window. To restore it is to double click the project explorer window .

When setting options on the docking tab is unchecked, the window will be placed in the programming workspace like the code window there. Windows placed in the programming workspace will have maximize or minimize controls .

If a window such as the project explorer or properties window is closed, then to display it again is through the View menu and selecting one of the windows you want to display.

Alright, I'll suffice for the discussion of the Visual Basic Editor (VBE) in Excel this time, next time I'll update again if needed. The main target of our discussion this time is to introduce you to the Visual Basic Editor which is also often referred to as the VB Editor or VBE as a tool that you will often use in creating VBA codes.

Oh yes, if you like Support by commenting and sharing this guide , so I can be more excited to write the next guide or tutorial.

Finally, hopefully useful and see you in the next series of Basic VBA guides.
Leave a Comment