我有一个大的一维数组,其中包含一些我想一次性在整个excel列中打印的数字。
这是我的代码:
Sub writeTimeDiff()
Dim i As Long
Dim j As Long
Dim lastRow As Long
Dim diffArr() As Variant
lastRow = Sheets("AUX").Range("A1").End(xlDown).Row
ReDim diffArr(lastRow)
j = 2
For i = 0 To lastRow
'Store the difference between two values in a row in the array
tsIN = Sheets("AUX").Cells(j, 3).value
tsOUT = Sheets("AUX").Cells(j, 4).value
diffArr(i) = tsOUT - tsIN
j = j + 1
Next i
'I'd like it to print the array throughout the entire F column (Starting in F2)
Sheets("AUX").Range("F2:F" & lastRow).value = diffArr
End Sub
但似乎只打印数组的第一个值:
这是我真正需要的:
任何帮助将不胜感激
答案 0 :(得分:2)
默认情况下,一维数组被视为行,因此您需要对其进行转置以转换为列。
Sheets("AUX").Range("F2:F" & lastRow).Value = Application.Transpose(diffArr)