Unique records' Sums

iknowu99

Well-known Member
Joined
Dec 26, 2004
Messages
1,158
Column C is product name and Column D to Column G the products associated sales figures

the problem is these products repeat throughout C - i plan to have a unique Column C with summed values for each product :eek:

help is appreciated
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Something like this:
Book4
ABCD
1ProductRevenueProductTotal
2Apples$1Berries$26
3Berries$2
4Orange$3
5Apples$4
6Berries$5
7Orange$6
8Apples$7
9Berries$8
10Orange$9
11Apples$10
12Berries$11
13Orange$12
Sheet1


Smitty
 
Upvote 0
Hi
it will display the result in col J:N
Code:
Sub test()
Dim dic As Object, a, i As Long, w(), n As Integer, y
Set dic = CreateObject("Scripting.dictionary")
dic.CompareMode = vbTextcompare
a = Range("c1",Range("c" & Rows.Count).End(xlUp)).Resize(,5).Value
For i = 1 To UBound(a,1)
   If Not IsEmpty(a(i,1)) Then
      If Not dic.exists(a(i,1)) Then
         ReDim w(1 To 5)
         w(1) = a(i,1)
         For ii = 2 To 5
            w(ii) = a(i,ii)
         Next
         dic.add a(i,1), w
      Else
         w = dic(a(i,1))
         For ii = 2 To 5
            w(ii) = Application.Sum(w(ii),a(i,ii))
         Next
         dic(a(i,1)) = w
      End If
   End If
Next
y = dic.items : Set dic = Nothing : Erase a
With Range("j1")
   For i = 0 To UBound(y)
      .Offset(i).Resize(,UBound(y(i)+1).Value = y(i)
   Next
End With
end Sub
 
Upvote 0

Forum statistics

Threads
1,214,897
Messages
6,122,148
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top