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

后端 未结 3 875
没有蜡笔的小新
没有蜡笔的小新 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条回答
  •  猫巷女王i
    2020-12-28 19:51

    If I may expand the accepted answer, I propose:

    [a1].Resize(UBound(arrayData) - LBound(arrayData) + 1) = Application.Transpose(arrayData)
    

    That would be the safe way. This will work no matter if you declare your array variable as:

    Dim arrayData(0 to 2) 
    

    or

    Dim arrayData(1 to 3) 
    

    The accepted answer works only in the second case.

    The proposed way might be useful if the size of array is unknown and you declare your arrayData as:

    Dim arrayData()
    

提交回复
热议问题