What is a VBA Module and How is a VBA Module Used?

Since 1998

What is a VBA Module and How is a VBA Module Used?

Excel VBA Tutorial

Presented below is a brief introduction to a VBA module and their uses.

A VBA module is where you type your computer code. The code you type in a module is run to command a program and perform other tasks.

What is a VBA module.

VBA code is typed and viewed in the VBA Editor in what are called modules. A collection of modules is what is called a VBA project. In the VBA Editor, a VBA module when viewed resembles and behaves like a Word document in both basic organization and typing. When viewed, a VBA module will appear in its own window within the VBA Editor. Think of modules as organizational folders for your code, you add VBA modules as needed to a project to organize and run code.

VBA modules come in three different flavors, when just starting off, you will be typing in a Standard module. The other two are Object and Class modules.

Excel VBA Modules
> > > >
In the Excel VBA example above, the three module types can be seen in the Editor, they are: Standard, Class and Object. When typing your VBA code, you make use of the Object and Standard modules the most to create your program. The most common one to use is the Standard module. If you want to build a Class module, it is better to use VB.Net and call it.

What is in a VBA module.

Modules are made up of elemental building blocks called procedures. Procedures are used to organize and run your code in a module. Think of a paragraph in a word document and you are on the right track. You type Excel commands, variables, arrays, loops, logic, functions,... in your VBA module procedures and then run the procedure to control Microsoft Excel and perform various other tasks.

Excel VBA Delete Column
> > > >
In the Excel VBA example above, a simple Sub procedure has been written that deletes column C from the active worksheet when run. The procedure is defined by the Sub and End Sub lines of code.

How to view and control a VBA module.

To view a module, just double click on its icon in the Project Explorer window in the VBA Editor. Standard modules are located under the Modules folder. Object modules are located under the Microsoft Excel Objects folder. Class modules are located under the Classes folder. Note that in Microsoft Excel, modules located under the Modules folder or Classes folder can be removed by right mouse clicking on their icons in the Project Explorer window and selecting Remove. They can also be added via the Insert menu.

Excel VBA Double Click Module
> > > >
In the Excel VBA example above, the Module1 standard module can be viewed by double clicking on its icon in the Project Explorer window. It will be displayed in a window on the right-hand side of the Editor. The module is located under the Modules folder in the window.
04/06
< Back
Next >
Facebook Contact Us Newsletter
Need Help? Please call us at 1.866.924.6244

Excel Software Design/Consulting

- Microsoft Excel Software

- Microsoft Excel Consulting

Microsoft Excel Products

- Excel Self-Study Manuals

Copyright © 2002-2019

EMAGENIT All Rights Reserved