View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone[_2_] Jim Cone[_2_] is offline
external usenet poster
 
Posts: 1,549
Default Dynamic Creation of Arrays - Sorting into Bins problem

A very good place to start are these 3 subject areas in Excel VBA help...
Using Arrays
Declaring Arrays
Understanding Parameter Arrays
'---
Sub Demo()
Dim aThinAir() As String
Dim x As Long
Dim y As Long
Dim z As Long

x = 10: y = 5: z = 5
ReDim aThinAir(1 To x, 1 To y, 1 To z)
aThinAir(1, 2, 3) = "sludge"

MsgBox aThinAir(1, 2, 3)
End Sub
'---
Jim Cone
Portland, Oregon USA .
http://www.mediafire.com/PrimitiveSoftware .
(free and commercial excel programs)





"Chris Flockhart"
wrote in message
...
Hi

In my vba code, I have an array of "structures", where the structure
has several fields including a User Name and other parameters. The
list is effectively unsorted as it has been created by reading a file
that contains entries in chronological order.

So far so good.

What I now want to do is to go through this array and produce a set of
new arrays, one per individual User Name, which each contain entries
from the original array that are specific to that UserName.

I also want to maintain a further array which keeps track of all of
the User specific arrays I have created.

This is a classic issue of processing a list into bins, dynamically
creating and reallocating the result bins as each item in the original
list is processed. I would have no problem implementing this in C,C++,
or Java, but I am unsure as to how to create an array from thin air at
run time in VBA.

I do not want to use magic numbers to create a "large enough" array,
as I would like this solution to be scalable.

Can anyone either describe how to create arrays completely dynamically
in vba, or point me at code which handles the sorting into bins
problem.

Thanks

Chris