merge duplicates and sum certain totals

sangsterexcell

New Member
Joined
Dec 11, 2014
Messages
11
[TABLE="width: 500"]
<tbody>[TR]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[TD]D
[/TD]
[TD]E
[/TD]
[TD]F
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]DESCRIPTION
[/TD]
[TD]STOCK#
[/TD]
[TD]PO REORDER#
[/TD]
[TD]QTY SOLD TY
[/TD]
[TD]QTY SOLD LY
[/TD]
[TD]QTY SOLD TO DATE
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]AA
[/TD]
[TD]1
[/TD]
[TD]FC1
[/TD]
[TD]6
[/TD]
[TD]3
[/TD]
[TD]18
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]AA
[/TD]
[TD]1
[/TD]
[TD]FC1
[/TD]
[TD]5
[/TD]
[TD]2
[/TD]
[TD]25
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]AA
[/TD]
[TD]1
[/TD]
[TD]FC1
[/TD]
[TD]1
[/TD]
[TD]5
[/TD]
[TD]63
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]BB
[/TD]
[TD]2
[/TD]
[TD]33
[/TD]
[TD]10
[/TD]
[TD]2
[/TD]
[TD]33
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]BB
[/TD]
[TD]2
[/TD]
[TD]33
[/TD]
[TD]5
[/TD]
[TD]5
[/TD]
[TD]18
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]BB
[/TD]
[TD]2
[/TD]
[TD]33
[/TD]
[TD]3
[/TD]
[TD]3
[/TD]
[TD]21
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]CC
[/TD]
[TD]3
[/TD]
[TD]15
[/TD]
[TD]6
[/TD]
[TD]9
[/TD]
[TD]19
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]CC
[/TD]
[TD]3
[/TD]
[TD]15
[/TD]
[TD]4
[/TD]
[TD]5
[/TD]
[TD]85
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]DD
[/TD]
[TD]4
[/TD]
[TD]A4
[/TD]
[TD]15
[/TD]
[TD]3
[/TD]
[TD]45
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]DD
[/TD]
[TD]4
[/TD]
[TD]A4
[/TD]
[TD]11
[/TD]
[TD]8
[/TD]
[TD]32
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]DD
[/TD]
[TD]4
[/TD]
[TD]A4
[/TD]
[TD]9
[/TD]
[TD]11
[/TD]
[TD]63
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]DD
[/TD]
[TD]4
[/TD]
[TD]A4
[/TD]
[TD]5
[/TD]
[TD]6
[/TD]
[TD]25
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I need to merge duplicates and sum sales totals however I need to keep certain columns information as it is and not summed. I tried consolidate function however I lose info I need. Above is an example of what I have.

I need it to look like in the same order of columns with my last 3 columns summed:
AA 1 FC1 11 10 106



How can I do this?
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
try this


Code:
Sub MergeData()
Dim LR As Long, i As Long

Application.ScreenUpdating = False
i = 2
LR = Range("A" & Rows.Count).End(xlUp).Row
Do
    IFind = Cells(i, 1)
    sAmt = WorksheetFunction.SumIf(Range("A:A"), IFind, Range("D:D"))
    sAmt2 = WorksheetFunction.SumIf(Range("A:A"), IFind, Range("E:E"))
    sAmt3 = WorksheetFunction.SumIf(Range("A:A"), IFind, Range("F:F"))
    Cells(i, 4) = sAmt
    Cells(i, 5) = sAmt2
    Cells(i, 6) = sAmt3
    SR = Cells(i + 1, 1).Address(False, False)
    Range("A:A").AutoFilter Field:=1, Criteria1:="=" & IFind
        
    x = WorksheetFunction.CountIf(Range("A:A"), Range("A" & i))
    If x > 1 Then
    Range(SR & ":A" & LR).EntireRow.Delete
    End If
    Range("A:A").AutoFilter
    
    i = i + 1
    LR = Range("A" & Rows.Count).End(xlUp).Row
    If LR = i Then GoTo 0
    
Loop Until IsEmpty(Cells(i, 1))
      
0
MsgBox "Done"
Application.ScreenUpdating = True
    
End Sub
 
Upvote 0
Thank you this did the job I was looking for and i appreciate it. Someday I need to take a class to understand how macros works.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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