8. Arrays

An array is a type of variable that can be used to hold more than one piece of data. For example, if you have to work with the name and address of a client, your first thought might be to assign one variable for the name and another for the address of the client. Instead, consider using an array, which can hold both pieces of information—and not for just one client but for hundreds.

Declaring an Array

You declare an array by adding parentheses after the array name and specifying the number of array elements in the parentheses:

Dim myArray(2) ...

Get Excel 2016 VBA and Macros now with O’Reilly online learning.

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