VBA-Excel: Arrays – Multi Dimensional Array

Multi Dimensional array has more than 2 dimensions.

For creating multi dimensional array, Follow the below status:

  • Declare the multi dimensional Array
  • Store values in array
  • Retrieve values from array

 

Declare the multi dimensional Array

Dim arrMatrix(1 To 9, 1 To 3, 1 To 3)

Store values in array

Read more

VBA-Excel: Arrays – One Dimension, Dynamic Array

Dynamic array means when size of the array is not fixed at the start of the program,  the size changes dynamically.

Use ReDim, For Resizing the size of the array.

If you just you ReDim to changing the size of an array, the already stored values in array will be deleted, if you want to keep the old values of an array while resizing the array, use Presereve keyword along with ReDim

ReDim Preserve arrArrayName(newSize)

Example: Store all the available values in column A, into an Array.

For creating one dimensional static array, follow the below steps

  • Declare an Array
  • Resize the array
  • Store values in array
  • Retrieve values from array.

Read more