My code is running into a Run-time error 9 (Subscript out of range).
When the code is debugged, the line printed in red is highlighted.
Here is my function:
At the error, i = 1, Key = "GEMS" theDict(key) = "Percentage", theDict has a count of 566, and the ubound(thearray) figure is 571.
I can't figure out why I am getting a out of range error.
When the code is debugged, the line printed in red is highlighted.
Here is my function:
Code:
Function populateDict(thearraY As Variant, retunArray As Variant) As Variant
Dim i As Integer
Dim key As Variant
For i = 1 To UBound(thearraY)
If theDict.Exists(thearraY(i, 2)) Then
theDict(thearraY(i, 2)) = theDict(thearraY(i, 2) + thearraY(i, 8))
Else
theDict.Add key:=thearraY(i, 2), Item:=thearraY(i, 8)
End If
Next i
i = 1
ReDim Returnarry(UBound(thearraY), 2)
For Each key In theDict.Keys
[COLOR=#ff0000]
returnArray(i, 1) = key[/COLOR]
returnArray(i, 2) = theDict(key)
i = i + 1
Next key
End Function
At the error, i = 1, Key = "GEMS" theDict(key) = "Percentage", theDict has a count of 566, and the ubound(thearray) figure is 571.
I can't figure out why I am getting a out of range error.