noname used his keyboard to write :
Hi Garry,
i get a type mismatch error on the following line:
vTextIn(n) = Split(vTextIn(n), sDelimiter)
any ideas why this is happening? i have declared vTextIn as a variant.
The code I posted was flagged as '<aircode' meaning it was intended
to illustrate the concept of creating an array of arrays. In all
probability it will be necessary to use ReDim Preserve on a new array
and put each element of the source array into a new array rather than
back into the source array. Also, it may require using another variable
before populating the element...
Dim vTemp As Variant
vTemp = Split(vTextIn(n), sDelimiter)
vTextIn(n) = vTemp
...where you create an array of the source array's element and place
that back into the same element 'as an array'. This might be how VBA
needs it to be so you don't get the 'type mismatch' error. Otherwise...
Dim vNewArray() As Variant, vTemp As Variant
vTemp = Split(vTextIn(n), sDelimiter)
ReDim Preserve vNewArray(n): vNewArray(n) = vTemp
...which is probably the best approach.
I don't have data to test this and so is why I flagged it as
'<aircode'. Mostly, I dump entire ranges into a Variant and work with
that because it's usually easier/faster than looping cells. For
example, a range of table data ("A1:E10") results in a 10Row x 5Col 1
based array. So...
myArray(1, 1) reps Cells(1, 1) [$A$1] of the range;
myArray(2, 2) reps Cells(2, 2) [$B$2] of the range;
myArray(1, 5) reps Cells(1, 5) [$E$1] of the range...
--
Garry
Free usenet access at
http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc