Output VBA Array Elements to One Cell in Excel

前端 未结 1 338
故里飘歌
故里飘歌 2021-01-23 14:26

So i have a vba code that creates an array with multiple elements. I would like to output those elements into one cell in excel. Im able to output its elements to multiple cells

1条回答
  •  被撕碎了的回忆
    2021-01-23 14:51

    If the array is declared as a String or Variant then you can use Join:

    Sub AllIntoOne()
        Dim arr(1 To 3) As Variant
        arr(1) = 4
        arr(2) = 54
        arr(3) = 3
        Range("A1") = Join(arr, ",")
    
    End Sub
    

    The delimiter "," defaults to a space if not supplied, but can be an empty string "" if no separation is required.

    0 讨论(0)
提交回复
热议问题