将多维数组的一行发送到工作表



我有一个大的二维(550行乘260列)数组,并希望将数组的完整行发送到电子表格(与数组的顺序不同)。我坚持从二维数组中拾取单个行(说行12)并将其放在工作表上。是否将目标设置为调整单元格大小?

请,任何帮助将非常感激!

可以使用以下函数:

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是您的2D数组的名称

相关内容

  • 没有找到相关文章

最新更新