Why am I getting the above error on executing the code below:
VBA Code:
Sub Sett()
Dim x, i, ii, u(), dic As Object, z As String
Set dic = CreateObject("Scripting.Dictionary")
dic.CompareMode = vbTextCompare
x = Sheets("Settlement").Range("a1").CurrentRegion.Resize(, 25).Value
rcnt = UBound(x, 1)
ccnt = UBound(x, 2)
ReDim u(1 To 3)
For i = 12 To rcnt
If x(i, 3) Like "Order" Then
z = x(i, 4) '& ";" & x(i, 3)
If Not dic.exists(z) Then
u(1) = x(i, 4)
u(2) = x(i, 18) + x(i, 19) + x(i, 20) + x(i, 21) + x(i, 22) + x(i, 23) + x(i, 24)
u(3) = x(i, 25)
dic.Add z, u
Else
u(2) = u(2) + x(i, 18) + x(i, 19) + x(i, 20) + x(i, 21) + x(i, 22) + x(i, 23) + x(i, 24)
u(2) = u(2) + x(i, 25)
End If
End If
Next i
Sheets("Collection").Rows("4:" & Rows.Count).ClearContents
Sheets("Collection").Cells(4, 1).Resize(dic.Count, 3).Value = Application.Transpose(Application.Transpose(dic.items))
End Sub