Excel VBA: Need Workaround for 255 Transpose Character Limit When Returning Variant Array to Selected Range

可紊 提交于 2019-11-29 15:57:18

This works for me:

Function Over255()

    Dim myArray(3)  As String '<<<<< not variant

    myArray(0) = String(300, "a")
    myArray(1) = String(300, "b")
    myArray(2) = String(300, "c")
    myArray(3) = String(300, "d")

    'Over255 = Application.Transpose(myArray())
    Over255 = TR(myArray)

End Function

'like Application.Transpose...
Function TR(arrIn) As String()
    Dim arrOut() As String, r As Long, ln As Long, i As Long

    ln = (UBound(arrIn) - LBound(arrIn)) + 1
    ReDim arrOut(1 To ln, 1 To 1)
    i = 1
    For r = LBound(arrIn) To UBound(arrIn)
        arrOut(i, 1) = arrIn(r)
        i = i + 1
    Next r
    TR = arrOut

End Function

Seems like you need to return a string array and Application.Transpose doesn't do that

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!