Chapter 22. VBA Essentials

A VBA procedure is a recipe or an organized set of statements written in the VBA language to carry out certain tasks. The statements or instructions that make up the recipe are analogous to sentences in English. In this chapter, I discuss the vocabulary and syntax of the VBA language that you need to know to write the statements; I also cover the rules for organizing them into procedures that VBA can follow to do what you want done.

You do not necessarily have to read everything in this chapter right away. You may want to familiarize yourself with the contents and then refer to specific sections as you need them. The best way to learn most of this material is to use them in models. The sooner you start developing models, the faster you will master this material.

An Overview of VBA

An Overview of VBA

You have already had an overview of how VBA works from the example in the previous chapter. Let me reiterate a few points for emphasis.

In both Excel and VBA, you perform actions. These actions are mostly calculations with numbers, but they can also be creating charts, formatting worksheets, and so forth. In VBA, you perform actions by executing VBA code, which is a series of VBA instructions or statements. Unlike in Excel, the actions do not take place as you write the instructions. After you write them, you have to execute them to perform the actions.

You organize the instructions in one of two kinds of VBA procedures for logical and other reasons. A model can ...

Get Financial Analysis and Modeling Using Excel and VBA now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.