I have code like this
Sub MG18Sep51
Dim Rng As Range, Dn As Range
Dim oTri As String, Q
Dim Mth As Date
Set Rng = Range(Range("E2"), Range("E" & Rows.Count).End(xlUp))
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
For Each Dn In Rng
oTri = Dn & Dn(, 2) & Dn(, 4)
If Not .Exists(oTri) Then
.Add oTri, Array(Dn, Dn(, 2), MonthName(Month(Dn(, 3))), Dn(, 4), Dn(, 5))
Else
Q = .Item(oTri)
Q(4) = Q(4) + Dn(, 5).Value
.Item(oTri) = Q
End If
Next
Range("K2").Resize(.Count, 5) = Application.Transpose(Application.Transpose(.Items))
End With
End Sub
but this is giving type mismatch error with me can anyone tell me the reason
Sub MG18Sep51
Dim Rng As Range, Dn As Range
Dim oTri As String, Q
Dim Mth As Date
Set Rng = Range(Range("E2"), Range("E" & Rows.Count).End(xlUp))
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
For Each Dn In Rng
oTri = Dn & Dn(, 2) & Dn(, 4)
If Not .Exists(oTri) Then
.Add oTri, Array(Dn, Dn(, 2), MonthName(Month(Dn(, 3))), Dn(, 4), Dn(, 5))
Else
Q = .Item(oTri)
Q(4) = Q(4) + Dn(, 5).Value
.Item(oTri) = Q
End If
Next
Range("K2").Resize(.Count, 5) = Application.Transpose(Application.Transpose(.Items))
End With
End Sub
but this is giving type mismatch error with me can anyone tell me the reason
Last edited: