I am getting a mismatch error at the line highlighted in red. The error occurs after the function is ran. I am confused because I created both items variants. How could there be a mismatch?
Code:
Option Explicit
Option Base 1
Dim theDict As New Scripting.dictionary
Sub Create_ownership()
Dim capitalOwnerArray() As Variant
[COLOR=#ff0000][B]capitalOwnerArray = populateDict(capitalArraY)[/B][/COLOR]
End Sub
Function populateDict(thearraY As Variant) As Variant
Dim i As Integer
Dim key As Variant
Dim returnarray() 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
ReDim returnarray(UBound(thearraY), 2)
Erase thearraY
i = 1
For Each key In theDict.Keys
returnarray(i, 1) = key
returnarray(i, 2) = theDict(key)
i = i + 1
Next key
thearraY = returnarray
End Function