读入数组时无法解释的VBA溢出错误

时间:2017-03-24 11:43:37

标签: excel-vba vba excel

新手在这里遇到了一个令人困惑的问题,即vba溢出错误

我正在填充一个数组,其大小为变体,每行有三个数据

With ActiveSheet
    For n = 2 To EndRow 'For each data row in the raw data sheet
        rawreadtime = .Cells(n, 1).Value 'Read time into array
        rawreadvol = .Cells(n, 8).Value 'Read corrected volume
        rawreadtest = .Cells(n, 3).Value 'Read which experiment number the data is for
        rawreadcounter = .Cells(n, 7).Value 'Read the number of bucket tips

Debug.Print "rawreadtest = "; rawreadtest; "rawreadcounter = "; rawreadcounter; "rawreadtime = "; rawreadtime


        RawData(1, rawreadtest, rawreadcounter) = rawreadtime 'Load the time data into the raw data array
        RawData(2, rawreadtest, rawreadcounter) = rawreadvol 'Load the volume data into the raw data array
    Next
End With

数组维度是 1到2,1对NumTests(= 7),1到MaxCounter(= 133)

数组索引的值为:

1; rawreadtest = 4; rawreadcounter = 1;

我正在阅读的数据是rawreadtime = 20/03/2017 21:56:51

代码落在第一个“Rawdata(1,.....)”。如果我注释掉那一行,下一行就可以了。

这已经工作了几周,现在因溢出错误而崩溃。我怀疑它是因为我们现在拥有的数据比以前多,但无法确定。

非常感谢任何想法。

0 个答案:

没有答案