将multidimensional array的行发送到工作表

我有一个大的二维(550行,260列)数组,并希望将数组的整行发送到一个电子表格(不是在数组中相同的顺序)。 我坚持从二维数组中挑选一个单独的行(比如第12行)并将其放在工作表上。 你设定的目的地resize的单元格?

请任何帮助将不胜感激!

您可以使用以下function:

Function Get2DArrayRow(arr2D As Variant, irow As Long) As Variant ReDim rowArr(LBound(arr2d, 2) To UBound(arr2d, 2)) As Variant Dim i As Long, j As Long For j = LBound(arr, 2) To UBound(arr, 2) rowArr(j) = arr2D(irow, j) Next j Get2DArrayRow = rowArr End Function 

被利用如下:

 Dim rowArr As Variant rowArr = Get2DArrayRow(arr2D, 12) '<-- retriev the 12th row of your 2D array ActiveSheet.Range("A20").Resize(, UBound(rowArr)).Value = rowArr '<-- write in row 20 of currently active sheet the 12th row of your 2D array 

在那里我假设arr2D作为你的二维数组的名称