View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Robert Crandal Robert Crandal is offline
external usenet poster
 
Posts: 309
Default Dealing with unknown array sizes

I have a multi-dimensional array which is initially defined
as follows:

Dim MyArr() as String

My VBA code will then search all rows that contain data.
(BTW, each row contains 5 columns of data.)

If a row of data is found that matches the search criteria,
I want to place all that string data into the "MyArr" array.
So, if my search yields 230 rows of string data, I want my final
array size to be EXACTLY 230 rows by 5 columns, or:

ReDim MyArr (1 to 230, 1 to 5)

Can I redimension the array each time a search hit is
found and continuously add data to this array?? I guess I'm
really looking for a string array that grows each time a search
hit is found.

I know I could create an oversized array to begin with, but
in my case it is important that my array size be EXACTLY
the same number as the total number of rows that I will place
in the array. Anybody know what I can do???

Thank you!