3. Understanding Program Variables

In This Chapter

• Learning why variables are useful

• Declaring variables for use in your macros

• Understanding the different types of variables

• Learning to use array variables and constants

• Using techniques that help you avoid the most common variable errors

Your VBA procedures often will need to store temporary values for use in statements and calculations that come later in the code. For example, you might want to store values for total sales and total expenses to use later in a gross margin calculation. Although you probably could get away with using the underlying application to store these values (in, say, a cell in an Excel worksheet), this almost always isn't very practical. Instead, VBA (like ...

Get Absolute Beginner's Guide to VBA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.