Creating and Transposing Array in VBA

前端 未结 2 1194
萌比男神i
萌比男神i 2021-01-14 04:40

I\'m hoping to load values in a range to an array and transpose that array to another location (different workbook)

I am using the below forum post to get an idea of

相关标签:
2条回答
  • 2021-01-14 05:35

    As I mentioned in comments, just use:

    tRangeArray.Value = Application.Transpose(MyArray)
    

    Sheets("sheet1").Range(tRangeArray).Value not working, because Range accepts either single parameter - string with range address (not range itself): Range(addr), either two parameters - top left and bottom right cells: Range(cell_1,cell_2)

    0 讨论(0)
  • 2021-01-14 05:40

    Similar, but using Resize and Ubound:

    Dim myarray As Variant
    myarray = Array(1, 2, 3, 4, 5)
    Sheets("sheet1").Range("A1").Resize(UBound(myarray), 1).Value = Application.Transpose(myarray)
    
    0 讨论(0)
提交回复
热议问题