View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default How do you create an Array of Arrays?

Another option is to use an array of types:

Private Type Days
Num() As Date
End Type

Const Dft As Long = 10

Private Sub CommandButton1_Click()
Dim Data() As Days
Dim i As Long

ReDim Data(1 To Dft)

For i = 1 To Dft
ReDim Data(i).Num(i)
Next

End Sub

NickHK

"BFike" wrote in message
...
I have an array, Dates(), which I want to contain arrays of Days().

Thus Jan 1, 2006 is a Day which I then want to store in Dates.

So Dates(1) would store all of the associated information for that Day.

Here
is the code that I have now. I do not consider myself to be a good

programmer
by any means so suggestions are welcome.

The Arrays, limit, and dayz are all public.

Here is the code where I load the Array of Arrays:

Range("F28").Select
Set myRange = Range("F28")
ReDim Dates(1 To dayz)
For j = 1 To dayz
ReDim Days(1 To limit)
Dates(j) = Days()
For i = 1 To limit
Days(i) = ActiveCell.Value
ActiveCell.Offset(1, 0).Activate
Next i
myRange.Offset(0, j).Activate
Next j

Here is the code where I try to do something sum up the values and then
write to the sheet but I keep getting the same Days array values over and
over.

Sub Sum_Days_Region()

Dim i, x, a, j As Variant
Dim sum()

Sheets("Total").Select
Range("A406").Select
Range(Selection, Selection.End(xlDown)).Select
ReDim sum(1 To dayz)

For Each x In Selection
For j = 1 To dayz
Dates(j) = Days()
For i = 1 To limit
If District(i) & " - " & Brand(i) = x.Value Then
sum(j) = sum(j) + Days(i)
End If
Next i
Next j

Range(x.Address).Select
ActiveCell.Offset(0, 28).Activate
For a = 1 To dayz
ActiveCell.Value = sum(a)
ActiveCell.Offset(0, 1).Activate
sum(a) = 0
Next a

Next x

End Sub