One of the first steps in understanding VBA is to understand the terminology. As we mentioned in the previous chapters, VBA stands for Visual Basic for Applications. Within the VBA window, there are several areas in which you need to understand.
Below we will review how to setup a Modules as well as Sub and Function procedures.
Module
A module is the area where the code is written. When you open a new VBA window, you will need to add a module.
To do this, select Insert – Module.
In the picture above, you can see how a module sheet is added. You can add multiple modules to a project.
Procedures
There are two main types of Procedures in Excel.
- Sub
- Function
Sub Procedures
Sub procedures are always enclosed within Sub and End Sub statements. A sub procedure does NOT return a value.
Function
A function in the world of programming languages in designed to be used multiple times throughout your code. The advantage of using a function is it’s ability to be reused in multiple code segments. Unlike a sub procedure, a function will return a value.
Microsoft VBA Glossary – A complete list of terms compiled by Microsoft
Let’s continue! Learn how to add comments to your VBA code. VBA Comment Structure