The array fills out the values in a row and column format. When you use a two dimensional array, think of the output with an x and y axis. The next dimension contains indexes from 0 to 3. The first dimension contains indexes 0 and 1. In the above code, a two dimensional array is created.
The following code shows you how to create a multidimensional array. In cases where you need to perform analytics or two dimensions of data, you use a multidimensional array. In most of your VBA code, you'll use single dimensional arrays. The data type is set to string and the variable can contain one dimension of variables assigned to indexes 0 to 2.
The following code shows you how to create a single dimensional array.
Single dimensional arrays carry one dimension of values. In some cases, you'll also need to know how to work with multidimensional arrays. Single dimensional arrays are the most common, so they are the ones often seen in code examples. If you've ever worked with any other programming languages, you are probably familiar with single dimensional arrays. Instead of creating 10 variables, you can create one and store those 10 values in each index.ĭeclaring Single Dimensional and Multidimensional Arrays Arrays are beneficial when you need to store several values into one variable. In this article we will get more detailed into arrays, how they work, creating multidimensional arrays, and looping through them to work with their data.