# Unique records' Sums

#### iknowu99

##### Well-known Member
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

help is appreciated

### Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Would SUMIF() work?

Or a Pivot table?

Smitty

not sure, i was thinking VBA

how would sumif work?

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

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
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``````

sweeet

Replies
2
Views
142
Replies
22
Views
979
Replies
0
Views
93
Replies
3
Views
102
Replies
4
Views
348

1,216,496
Messages
6,130,987
Members
449,612
Latest member
geniusufo007

### 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.

### Which adblocker are you using?

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

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