The way that cell addresses are stored in an array may cause the
Range method to fail when you select the entire array of cells. To illustrate this, the following array (named myArray) loads an array of cell addresses and allows the
Range method to select the entire range:
Dim myArray
myArray = Selection.Address
Range(myArray).Select
By using this statement, you store the selected range to the myArray array in the following format:
myArray("A1, A3, A5, A7")
However, the following Visual Basic for Applications method stores the
selected cells to the array. Selecting the array results in one of the macro error message described in the "Symptoms" section.
Option Base 1
Sub ArrayExample()
Dim myArray()
For counter = 1 To 1
ReDim Preserve myArray(counter)
myArray(counter) = Cells(counter, 1)
Next counter
Range(myArray).Select
End Sub
By using this looping procedure, you store the selected range to the myArray array in the following format:
myArray("A1", "A3", "A5", "A7")
This format causes the
Range method to fail when you select the entire array of addresses.