I have a code where in one sub I begin to populate an array. Later in another sub I am trying to populate the same array with additional information. It is not working because I am receiving an runtime error 9. I was told that I cannot do this because redim does not work with first dimension of my array.
My question is there another way I can get this done? Below is what I have so far.
The error takes place:
Sub PartTwo()
ReDim WorkArray(1 To GEMclass.NumofP, 1 To 4)
For c = 1 To UBound(FullArray, 1)
If GEMclass.g = FullArray(c, 1) Then
Count = Count + 1
WorkArray(Count, 1) = FullArray(c, 1)
WorkArray(Count, 2) = FullArray(c, 4)
WorkArray(Count, 3) = FullArray(c, 7)
WorkArray(Count, 4) = FullArray(c, 6)
End If
Next c
ReDim Preserve WorkArray(1 To GEMclass.NumofP, 1 To 4)
CumulativePartners = GEMclass.NumofP
End Sub
Sub PartThree()
For e = 1 To Count
If dict.Exists(WorkArray(e, 2)) Then
TempCP = CumulativePartners
CumulativePartners = CumulativePartners + dict(WorkArray(e, 2)).NumofP
For f = 1 To UBound(FullArray, 1)
If WorkArray(e, 2) = FullArray(f, 1) Then
For g = 1 To dict(WorkArray(e, 2)).NumofP
Dim test As Integer
test = TempCP + g
WorkArray(test, 1) = FullArray(f, 1)<---Runtime error 9
WorkArray(test, 2) = FullArray(f, 4)
WorkArray(test, 3) = FullArray(f, 7)
WorkArray(test, 4) = FullArray(f, 6)
Next g
End If
Next f
ReDim Preserve WorkArray(1 To CumulativePartners, 1 To 4)
Else
MsgBox "No"
End If
Next e
End Sub