Combine Unique Columns and sum up different values

  • Thread starter Thread starter sdnicsm
  • Start date Start date
S

sdnicsm

How easy is it to filter unique records in one column and have the tota
of another column sum'd up from the unique records:

CLIN Count
0001AA 5
0001AA 1
0001AA 5
0001AB 6
0001AB 38
0001AB 2
0001AB 11
0001AB 15
0004AC 12

End result being

CLIN COunt
0001AA 11
0001AB 72
0004AC 12

Any ideas on how to do with VBA
 
Here's one way

Sub Totals()
Dim i As Long
Dim prevVal As String

For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If Cells(i, "A").Value <> prevVal Then
Cells(i, "C").Formula = "=SUMIF($A$1:$A$100,""" & Cells(i,
"A").Value & """,$B$1:$B$100)"
prevVal = Cells(i, "A").Value
End If
Next i

End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top