Excel VBA function to print an array to the workbook

后端 未结 6 1759
心在旅途
心在旅途 2020-12-10 03:17

I\'ve written a macro that takes a 2 dimensional array, and \"prints\" it to equivalent cells in an excel workbook.

Is there a more elegant way to do this?



        
6条回答
  •  长情又很酷
    2020-12-10 04:12

    My tested version

    Sub PrintArray(RowPrint, ColPrint, ArrayName, WorkSheetName)
    
    Sheets(WorkSheetName).Range(Cells(RowPrint, ColPrint), _
    Cells(RowPrint + UBound(ArrayName, 2) - 1, _
    ColPrint + UBound(ArrayName, 1) - 1)) = _
    WorksheetFunction.Transpose(ArrayName)
    
    End Sub
    

提交回复
热议问题