View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Need help with dynamic array

It's quite straight-forward Peter.

Dim myarray()

iLastRow = Cells(Rows.Count,"A").End(xlUp).Row

Redim myarray(1 to 1)
'this simply sets the array up

For i = 1 To iLastrow
Redim Preserve myarray(1 To i)
'the array is preserved to the current index, preserving the data
myarray(i) = Cells(i,"A").Value
Next


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Peter Bernadyne"
<Peter.Bernadyne.24h3fy_1142026203.2698@excelfor um-nospam.com wrote in
message news:Peter.Bernadyne.24h3fy_1142026203.2698@excelf orum-nospam.com...

I see. Thanks very much.

That count code I've used countless times, actually, since I believe
you first showed it to me (3 yrs ago)...I am indebted to you for that,
indeed.

Just out of curiosity, how/when would I resize an array dynamically
using preserve? Would anybody be able to show me how to do this in a
loop?

Thanks again.


--
Peter Bernadyne
------------------------------------------------------------------------
Peter Bernadyne's Profile:

http://www.excelforum.com/member.php...fo&userid=7017
View this thread: http://www.excelforum.com/showthread...hreadid=521226