Home / MS-Excel / General Formatting

Understanding Program Variables

Your VBA procedures often 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 all programming languages) lets you store temporary values in special memory locations called variables. This tutorial explains this important topic and shows you how to use variables in your VBA procedures.