Writing an array to a range. Only getting first value of array

后端 未结 3 876
没有蜡笔的小新
没有蜡笔的小新 2020-12-28 19:05

I am trying to write an array to a range and I have tried several ways but no matter what, I always get only the FIRST value of the array over and over again.

Here i

3条回答
  •  梦谈多话
    2020-12-28 19:26

    Do this:

    arrayData = Array("A", "B", "C", "D", "E")
    
    [a1].Resize(UBound(arrayData) + 1) = Application.Transpose(arrayData)
    

    The important bit is the Transpose() function.

    But it is better to work with 2D arrays from the get go if you plan on writing them to the worksheet. As long as you define them as rows in the first rank and columns in the second, then no transposition is required.

提交回复
热议问题