Microsoft Office Tutorials and References
In Depth Information
Chapter 13: Introducing VBA
Chapter 13
Introducing VBA
An introduction to Visual Basic for Applications — Excel’s macro
programming language
How to use the Visual Basic Editor
How to work in the code windows of the Visual Basic Editor
T HIS CHAPTER INTRODUCES YOU to Visual Basic for Applications (VBA). VBA is
Excel’s programming language and it is used to automate various aspects of
Excel — including charts.
This chapter provides some basic background knowledge of VBA and the Visual
Basic Editor and sets the stage for the information presented in subsequent chapters.
VBA in a Nutshell
VBA is best thought of as Microsoft’s common application scripting language. VBA
is included with all Office 2002 applications, and it’s also available in applications
from other vendors. You use VBA to write procedures, frequently known as macros.
Following is a quick-and-dirty summary of what VBA is all about.
You perform actions in VBA by executing VBA code.
You write (or record) VBA code, which is stored in a VBA module.
VBA modules are stored in an Excel workbook, but you view or edit a module
using the Visual Basic Editor.
A VBA module consists of procedures.
A procedure is basically a unit of computer code that performs some action. Here’s
an example of a simple Sub procedure called Test. This procedure calculates a
simple sum and then displays the result in a message box:
Sub Test()
Sum = 1 + 1
MsgBox “The answer is “ & SumEnd Sub
Search JabSto ::

Custom Search