我有下面的代碼提取,它假設將數組的內容轉儲回工作表,但它似乎不工作,我卡住了..可以有人請幫忙,謝謝。轉儲Excel VBA數組到工作表不工作,
Dim aggressiveDriving(7000) As Variant
For i = 3000 To 7000
'simple kinematic equation
aggressiveDriving(i) = Math.Sqr((((aggressiveDriving(i - 1)/3.6)^2) + (2 * aggressive_decel))) * 3.6
Next
'at this stage, when I watch the array, it is populated with the expected values in double.
'now writing back to worksheet
With ActiveWorkbook.Worksheets("Current_Driving")
'if I replace 'aggressiveDriving with '0' then the dumping works with
'filling 0s
.Range(.Cells(2, "F"), .Cells(7002, "F")).value = aggressiveDriving
End With
謝謝Jeeped,工程就像一個魅力! – lukieleetronic
好聽。只需注意[TRANSPOSE](https://support.office.com/en-us/article/TRANSPOSE-function-ED039415-ED8A-4A81-93E9-4B6DFAC76027)功能的限制;我認爲這是一個有符號的int - 1(例如32,767)。請參閱[數據文件中的Excel VBA中的Error13](http://stackoverflow.com/questions/29451126/error13-in-excel-vba-in-data-file)以獲取快速的home-spun函數** my_2D_Transpose ** with無限。 – Jeeped
或者只是'Dim aggressiveDriving(1到7000,1)'而沒有轉置,因爲'cells'是一個二維數組,你還需要一個二維數組。邏輯否?此外,從1到3000的所有內容都將爲零,並被覆蓋。 –