I'm having an issue passing a Class variable into a collection. Here is the framework I'm trying to acheive:

Container (think of a big shipping container (this is a class))
Purchase Order (1)
Purchase Order (2) ---> Each container contains several POs (also a class)

The code runs fine when filling the PO class. Each PO has a variable common to the trailer number. After I collect all the POs I'm trying to divy them into Containers with a Key=Container number (the identity of the container).

The issue I'm having are the containers are creating only 1 PO that is empty. However, the number of containers being created is correct.

Here is the code:



[vba]
Private Function GetPOData(POs() As PO) As PO()
ReDim POs(1 To 1)
'check PO to see if it is on a container
C = 1
EndRow = ActiveSheet.UsedRange.Rows.Count
Range("A2").Select
Do If ActiveCell.Offset(0, 62) <> " " Then 'Checks for trailer number
Set POs(C) = New PO 'If trailer exists, records PO information
POs(C).POName = ActiveCell.Value
POs(C).Carrier = ActiveCell.Offset(0, 57).Value
POs(C).ProjInDCDate = ActiveCell.Offset(0, 52).Value
POs(C).PlanInDCDate = ActiveCell.Offset(0, 15).Value
POs(C).Entity = ActiveCell.Offset(0, 8).Value
POs(C).POType = ActiveCell.Offset(0, 12).Value
POs(C).Location = ActiveCell.Offset(0, 3).Value
POs(C).CaseCount = ActiveCell.Offset(0, 19).Value
POs(C).UnitsShpd = ActiveCell.Offset(0, 18).Value
POs(C).POWeight = ActiveCell.Offset(0, 67).Value
POs(C).POTrailer = ActiveCell.Offset(0, 62).Value
C = C + 1
ReDim Preserve POs(1 To C)
ActiveCell.Offset(1, 0).Select
Else 'If Trailer Number is empty, deletes row and moves to next line
ActiveCell.EntireRow.Delete
EndRow = EndRow - 1
End If
Loop While C <> EndRow
ReDim Preserve POs(1 To UBound(POs) - 1) 'Removes the last array because it is empty

GetPOData = POs

End Function '<----- This function works fine in creating the POs... Only placed as reference


Private Function GetContainerData(Containers() As Container, POs() As PO) As Container() '<------ Divvy them into containers
Dim ContExists As Boolean
ReDim Containers(1 To 1)
Set Containers(1) = New Container
C = 0

For Each PO In POs For C2 = 1 To UBound(Containers)
ContExists = False
If POs(C).POTrailer = Containers(C2).TrailerNum Then
Containers(C2).POs.Add (Value)
Containers(C2).POCount = Containers(C2).POCount + 1
Containers(C2).TrailerNum = POs(C).POTrailer
ContExists = True
C = C + 1
End If
Next C2
If ContExists = False Then
If Containers(1).TrailerNum <> "" Then
ReDim Preserve Containers(1 To UBound(Containers) + 1)
Set Containers(UBound(Containers)) = New Container
End If
Containers(UBound(Containers)).POs.Add (Value)
Containers(UBound(Containers)).POCount = Containers(UBound(Containers)).POCount + 1
If Containers(UBound(Containers)).TrailerNum = "" Then
Containers(UBound(Containers)).TrailerNum = POs(C).POTrailer
End If
C = C + 1
End If
Next PO
GetContainerData = Containers

End Function

'------Let/Get in Container Class ---------

Public Property Get POs() As Collection
Set POs = New Collection For pC = 1 To POs.Count
POs.Add pPOs(pC)
Next pC
End Property

Public Property Let POs(Value As Collection) Set pPOs = New Collection
For pC = 1 To Value.Count
pPOs.Add Value(pC)
Next pC
End Property




[/vba]

ANY help I can get would be amazing!!!!!!!!!!!!! (I've been stuck on this issue for about 2 days now)

Thanks a million!