Table of contents
Collapse the table of content
Expand the table of content

Can't change data types of array elements

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

ReDim can only be used to change the number of elements in anarray. 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).

© 2018 Microsoft