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).
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
Feedback
https://aka.ms/ContentUserFeedback.
Kommer snart: I hele 2024 udfaser vi GitHub-problemer som feedbackmekanisme for indhold og erstatter det med et nyt feedbacksystem. Du kan få flere oplysninger under:Indsend og få vist feedback om