Alan said:
. . .
But if the functions in the freely downloadable file at
http://home.pacbell.net/beban are available to your workbook, the
following will produce a 2-D array with the first row loaded, bounds 0
to 0, 0 to 2:
Dim BigArray
StringList = "foo1 foo2 foo3"
BigArray = Split(StringList, " ")
BigArray = TwoD(BigArray)
Alan Beban
Of course, having the first dimension bounds 0 to 0 doesn't leave room
for adding elements. To end up with first dimension bounds of, e.g., 0
to 5, add a line to the above:
ResizeArray BigArray,0,5
Or just use
Dim BigArray
StringList = "foo1 foo2 foo3"
BigArray = Split(StringList, " ")
ResizeArray BigArray, 0, 5, 0, 2
To get Harlan Grove's suggested code
v = Split("a b c d e f g h i j k l m n o p")
v = Application.WorksheetFunction.Transpose(v)
ReDim Preserve v(LBound(v, 1) To UBound(v, 1), 1 To 6)
v = Application.WorksheetFunction.Transpose(v)
to work I had to add ReDim v at the beginning; otherwise I got an
Invalid ReDim error message (in xl2002). And then the result (within the
variant variable) was a 1-based Variant() array--because that's what the
built-in Transpose function does--rather than a 0-based String() array.
If it were important to you for BigArray to be a true String() array
rather than a String() array within a variant variable (I doubt it is),
you could use
Dim BigArray() As String
ReDim BigArray(0 To 0)
StringList = "foo1 foo2 foo3"
Assign Split(StringList, " "), BigArray
ResizeArray BigArray, 0, 5, 0, 2
Alan Beban