我正在尝试使用工作表中的数据填充动态数组。我得到“错误 9 下标超出范围”。为什么?
Sub correct()
Dim row As Integer, i As Long
Dim constants() As Double 'this declares the dynamic array
row = 1
i = 0
ReDim constans(0) 'this resizes the array(rediminsion's the array)
Do Until ThisWorkbook.Sheets("Deg 4").Cells(row, 1).Value = ""
constants(i) = ThisWorkbook.Sheets("Deg 4").Cells(row, 1).Value
i = i + 1 'increments array index
ReDim Preserve constants(i) 'resize the array 1 larger and preserves previous data
row = row + 1 'increments the worksheet row
Loop
End Sub