Professional Documents
Culture Documents
Introduction to
VBA
BMGT 302
Business Application
Programming
Scott Hudson
What is VBA
A programming language created by Microsoft to
automate operations in applications
Excel, Access, Word, PowerPoint, and Outlook
File formats
Excel 2003 and earlier
All excel files ended with .xls extension
Trusted Locations: any .xlsm files in this folder (or its subfolders) will open
without any warning about enabling macros
Warning messages
Basic terminology
Lines of code
Must obey the rules of syntax
Think of it as an instruction to the computer to do
something
Program
all of the subs in an application
Running a Macro
Accessing VBE
VBE Interface
Immediate Window
useful for issuing one-line VBA commands
Understanding Modules
Standard modules
hold macros you create from scratch on your own or from the Macro
Recorder
UserForm modules
belong to a custom user interface object called a UserForm
Class modules
enables you to create your own objects programmatically
Worksheet modules
procedures are tied to various actions called events, such as
selecting a range or entering a value in a cell
Workbook modules
where code is maintained for handling workbook-level events
Object Browser
Color coding
With Statement
Inserting a Module
Renaming a Module
Deleting a Module