When I try to print items to an immediate screen and I get an onject required error.
This code is modified from a code I got online.
The debug higlights the line in red.
This code is modified from a code I got online.
The debug higlights the line in red.
Code:
Sub Herewegoagain()
Dim mainDict As New Dictionary, unique1051Dict As New Dictionary
Dim gemdata As Class1
Dim rg As Range
Dim i As Integer
Sheet1.Activate
Set rg = Sheet1.Range("a2").CurrentRegion
For i = 2 To rg.Rows.Count
Set gemdata = New Class1
gemdata.geM = rg.Cells(i, 2)
gemdata.entitY = rg.Cells(i, 3)
gemdata.parenT = rg.Cells(i, 5)
gemdata.parentName = rg.Cells(i, 6)
gemdata.bU = rg.Cells(i, 7)
gemdata.pcT = Round(rg.Cells(i, 8), 0)
gemdata.owneR = rg.Cells(i, 9)
If Cells(i, 5) = "" Then
gemdata.uKey = Cells(i, 2) & Cells(i, 6)
Else
gemdata.uKey = Cells(i, 2) & Cells(i, 5)
End If
mainDict.Add gemdata.uKey, gemdata
If gemdata.owneR = "Company" Then
unique1051Dict(gemdata.geM) = unique1051Dict(gemdata.geM) + gemdata.pcT
End If
Next i
printexamplE unique1051Dict
End Sub
Sub printexamplE(unique1051Dict As Dictionary)
Dim key As Variant, gemdata As Class1
Set gemdata = New Class1
For Each key In unique1051Dict.Keys
[COLOR=#ff0000]Set gemdata = unique1051Dict(key)[/COLOR]
Debug.Print gemdata.geM, gemdata.pcT
Next key
End Sub