Can't change data types of array elements
ReDim can only be used to change the number of elements in an array. This error has the following cause and solution:
- You tried to redeclare the data type of an array using ReDim.
Declare a new array of the type you want, and then use the conversion functions to assign each element of the old array to the corresponding element of the new array.
You can also place the array in a Variant variable. This can be done with a simple assignment:
Dim MyVar As Variant MyVar = MyIntegerArray()This creates a Variant containing an array tagged as the type of the original array. You can then assign variables of any valid VarType to the elements of the array within a variant.
For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).