how to automatically sum and merge rows based on same value in column?

chezchez

New Member
Joined
Nov 30, 2012
Messages
2
hello, can anyone help me perform the following calculation in excel please?

I have a long list of items and their quantities, example:
1010011
1010016
1010012
1010011
1010026
1010021
1010036
1010046
1010056
1010501
1010501
1010505
1010501
1010502
1010502
1010501

<tbody>
</tbody>

now i would like to merge all the rows with the same value in column A and add up the corresponding values in column B to return the following:


10100110
1010027
1010036
1010046
1010056
10105013

<tbody>
</tbody>

I am guessing I have to run a macro, but I have no idea how to do that... any help would be much appreciated!
thanks, chez
 
Sorry tried to post image didnt work. Data Headers Start at B4


Quote #13534
FINISHED
BCDEFGHIJKLM
CodeGAPWages Rate BilledEstCostnRatecostFeeFee2
CA 8810 $ 175,000 $ 175,0002.58% $ 2,375 $ 1,540 $ 3080.00%1.20% $ 1,2003.78% $ 3,575
CA 9008 $ 960,000 $ 960,00049.04% $ 194,452 $ 160,416 $ 32,0830.00%1.20% $ 3,00050.24% $ 197,452
CO 9014 $ 795,000 $ 795,0006.60% $ 24,899 $ 28,382 $ 5,6760.00%1.20% $ 1,8007.80% $ 26,699
Totals $ 1,930,000 $ 1,930,000 $ 221,726 $ 190,338 $ 38,068 $ 6,000 $ 227,726

<tbody>
</tbody>
----------------------------------------------------------------------------------------------------------------------------------
ORIGINAL

CA 9008 $ 250,000 $ 250,00033.42% $ 83,550 $ 41,775 $ 8,3550.00%1.20% $ 3,00034.62% $ 86,550
CA 8810 $ 100,000 $ 100,0001.76% $ 1,760 $ 880 $ 1760.00%1.20% $ 1,2002.96% $ 2,960
CO 9014 $ 150,000 $ 150,0003.57% $ 5,355 $ 5,355 $ 1,0710.00%1.20% $ 1,8004.77% $ 7,155
CA 9008 $ 710,000 $ 710,00015.62% $ 110,902 $ 118,641 $ 23,7280.00%0.00% $ -15.62% $ 110,902
CA 8810 $ 75,000 $ 75,0000.82% $ 615 $ 660 $ 1320.00%0.00% $ -0.82% $ 615
CO 9014 $ 645,000 $ 645,0003.03% $ 19,544 $ 23,027 $ 4,6050.00%0.00% $ -3.03% $ 19,544

<tbody>
</tbody>
 
Upvote 0

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Try this:-
Nb:- Your Dollar formatted numbers appear on my sheet as text, so I removed the dollars signs and reformatted as dollars.
Code:
[COLOR="Navy"]Sub[/COLOR] MG15Apr38
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] lst [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] col [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]Dim[/COLOR] nRng [COLOR="Navy"]As[/COLOR] Range, Q [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("B4"), Range("B" & Rows.Count).End(xlUp))
[COLOR="Navy"]With[/COLOR] CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    [COLOR="Navy"]If[/COLOR] Not .Exists(Dn.Value) [COLOR="Navy"]Then[/COLOR]
        .Add Dn.Value, Dn
    [COLOR="Navy"]Else[/COLOR]
        [COLOR="Navy"]For[/COLOR] n = 1 To 11
           .Item(Dn.Value).Offset(, n).Value = _
           .Item(Dn.Value).Offset(, n).Value + Dn.Offset(, n).Value
        [COLOR="Navy"]Next[/COLOR] n
           [COLOR="Navy"]If[/COLOR] nRng [COLOR="Navy"]Is[/COLOR] Nothing [COLOR="Navy"]Then[/COLOR]
                [COLOR="Navy"]Set[/COLOR] nRng = Dn
            [COLOR="Navy"]Else[/COLOR]
                [COLOR="Navy"]Set[/COLOR] nRng = Union(nRng, Dn)
            [COLOR="Navy"]End[/COLOR] If
  
    [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR]
[COLOR="Navy"]If[/COLOR] Not nRng [COLOR="Navy"]Is[/COLOR] Nothing [COLOR="Navy"]Then[/COLOR] nRng.EntireRow.Delete
[COLOR="Navy"]End[/COLOR] With
lst = Range("B" & Rows.Count).End(xlUp).Row
    Range("B" & lst + 1).Value = "Totals"
    col = Array(1, 2, 4, 5, 6, 9, 11)
    [COLOR="Navy"]For[/COLOR] n = 0 To UBound(col)
        Range("B" & lst + 1).Offset(, col(n)) = Application.Sum(Range("B4").Offset(, col(n)).Resize(lst - 3))
        Range("B" & lst + 1).Offset(, col(n)).NumberFormat = "[$$-409]#,##0"
    [COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Last edited by a moderator:
Upvote 0

Forum statistics

Threads
1,216,135
Messages
6,129,075
Members
449,485
Latest member
greggy

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