Jagged Arrays in Data | Text To Columns

蹲街弑〆低调 提交于 2019-12-05 03:40:19

You can assign an array to an array item like so:

Dim n As Long
n = 0
ReDim MyArray(2700 \ 60)
For i = 0 To 2700 Step 60
    MyArray(n) = Array(i, 1)
    n = n + 1
Next i

You are going correct. Instead of adding to string in loop, just create actual array items.

So this is what you will have:

Sub Sample()
    Dim ws As Worksheet
    Dim MyArray(20) As Variant      '<-- specify the number of items you want
    Dim i As Long

    For i = 0 To UBound(MyArray)
         MyArray(i) = Array(i * 60, 1)
    Next

    Set ws = ThisWorkbook.Sheets("Sheet1")
    ws.Columns(1).TextToColumns _
        Destination:=Range("A1"), _
        DataType:=xlFixedWidth, _
        FieldInfo:=MyArray, _
        TrailingMinusNumbers:=True
End Sub
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!