Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub nSum()
- Dim Rng As Range, Dn As Range, n As Long, Txt As String, Ac As Long
- Set Rng = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
- ray(1 To Rng.Count, 1 To 4) 'Column count ''***ERROR LINE***************
- With CreateObject("scripting.dictionary")
- .CompareMode = vbTextCompare
- For Each Dn In Rng
- Txt = Join(Application.Transpose(Application.Transpose(Dn.Resize(, 3))), ",")
- If Not .Exists(Txt) Then
- n = n + 1
- For Ac = 1 To 4: ray(n, Ac) = Dn.Offset(, Ac - 1): Next Ac
- .Add Txt, n
- Else
- ray(.Item(Txt), 4) = ray(.Item(Txt), 4) + Dn.Offset(, 3)
- End If
- Next
- n = .Count
- End With
- With Sheets("Sheet2").Range("A1").Resize(n, 4)
- .Value = ray
- .Borders.Weight = 2
- .Columns.AutoFit
- End With
- End Sub'
Add Comment
Please, Sign In to add comment