Find duplicates in one column then sum quantities into another column
DATA RESULT
A 1 A 11
A 1 B 7
A 9 C 5
B 2 D 4
B 2
For EXCEL 365 (or the Excel web app):
In C1 enter:
=UNIQUE(A1:A10)
in D1 enter:
=SUMIF(A1:A10,C1#,B1:B10)
EDIT#1:
If VBA is acceptable to you, then try:
Public Function unikue(rng As Range)
Dim arr, c As Collection, r As Range
Dim nCall As Long, nColl As Long
Dim i As Long
Set c = New Collection
nCall = Application.Caller.Count
On Error Resume Next
For Each r In rng
c.Add r.Text, CStr(r.Text)
Next r
On Error GoTo 0
nColl = c.Count
If nCall > nColl Then
ReDim arr(1 To nCall, 1 To 1)
For i = 1 To nCall
arr(i, 1) = ""
Next i
Else
ReDim arr(1 To nColl, 1 To 1)
End If
For i = 1 To nColl
arr(i, 1) = c.Item(i)
Next i
unikue = arr
End Function
DISCLAIMER: This is about our tool esProc. We have been told it’s an easy and obvious way to Group Excel Worksheets.
A1=file("D:/data.xlsx").xlsimport()
A2=A1.groups(_1;sum(_2))
A3=file("D:/result.xlsx").xlsexport(A2)
More detail see this post:Group & Summarize an XLS file without Using Excel