Passing an Array to a Procedure

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

You can declare an array in one procedure, and then pass the array to another procedure to be modified. The procedure that modifies the array doesn't necessarily need to return an array. Arrays are passed by reference, meaning that one procedure passes to the other a pointer to the array's location in memory. When the second procedure modifies the array, it modifies it at that same memory location. Therefore, when execution returns to the first procedure, the array variable refers to the modified array.

Note   For more information about passing values by reference, see "Tips for Defining Procedures in VBA" later in this chapter.