redim preserve 2 element array

CJBIRKIN

Drink!
Local time
Today, 16:30
Joined
May 10, 2002
Messages
256
Hi

I'm trying to resize an array as i go through a loop.

This is how i have dimensioned the array
Dim ColData() As Variant


then to start the array (ColNow is an unknown value)

Find ColNow

then

ReDim ColData(ColNow,0)

then with each iteration of the loop ArrayInty is increased by 1

arrayinty = arrayinty+1

ReDim Preserve ColData(ColNow, ArrayInty)


Trouble is it doesn't want to resize the array using redim preserve i get the subscript out of range error.


Any help??

Cheers

Chris
 
I think if you Redim before you increment it will solve your problem.

Code:
ReDim Preserve ColData(ColNow, ArrayInty+1) 
arrayinty = arrayinty+1

HTH,
Patrick
 
Hi

No apparently you can't do this. I did some more looking around and apparently it's not possible to redim an array with more than 1 element. go figure.

Chris
 

Users who are viewing this thread

Back
Top Bottom