我声明了一个Range数组
Dim aRange(1 to 5) as Range
我以后无法使用
在我的代码中调整数组大小ReDim Preserve aRange(1 to a)
我做错了什么或者我无法调整Range数组的大小。
答案 0 :(得分:2)
变化:
Dim aRange(1 to 5) as Range 'Static dimensioning, cannot be changed later on
由:
Dim aRange() as Range 'Declared as dynamic array, have to be redim before using it
所以:
Dim a as Integer
a = 6
Dim aRange() as Range 'Declared as dynamic array, have to be redim before using it
ReDim Preserve aRange(1 to 5)
ReDim Preserve aRange(1 to a)