0
下面的代碼加載一個範圍到一個數組:(?新的數據位)Excel的VBA負荷範圍分成數組溢出錯誤
Dim Data() As Variant
Dim i As Long
Erase Data
i = 2: Do Until Sheets("whatever").Cells(i, 1) = "": i = i + 1: Loop
Sheets("whatever").Activate
Data = Sheets("whatever").Range(Cells(2, 1), Cells(i, 37)).Value
這用來工作,但今天既然給了我運行時錯誤「6」 /溢出加載Data
陣列的行中。
i = 242703這確實是我想加載的最後一行。這對於數組來說可以是兩個大的嗎?
[此鏈接](http://www.cpearson.com/excel/LastCell.aspx)或[此鏈接](http://www.ozgrid.com/VBA/ExcelRanges.htm)不回答您的具體問題,但它提供了找到列中最後一個單元格的更好方法。 – 2014-10-01 17:42:24
[退出循環並將該範圍直接加載到一行代碼中的數組](http://stackoverflow.com/questions/18481330/2-dimensional-array-from-range/18481730#18481730) – 2014-10-01 17:59:22
您的代碼278575行和37列,每列都包含一個整數值,對我來說運行良好。也許需要在代碼/數據的其他地方查找問題? – barryleajo 2014-10-01 21:44:06