Summing Duplicates in column B

Cander

Board Regular
Joined
Mar 2, 2009
Messages
135
Is there a macro that will look for duplicate rows across columns C thru G and if a duplicate or duplicates are found to sum the numbers in column H of their row in column B of their row?<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
This is an example:<o:p></o:p>
The colors are here only to represent duplicates and are not normally on the sheet.<o:p></o:p>
Before macro is executed:<o:p></o:p>
<o:p>
Excel Workbook
ABCDEFGHI
1ThelmaCodeThelmaSumDuplicatesThelmaEaLftThelmaPieceSizeThelmaMaterialUsedThelmaStudBearingThelmaFloorThelmaSumLFTThelmaCornerChannel
20Ea2X410 STUD GR DF 116 1/4 KD2x4 NON-BEARING STUDS1st Floor337
30Ea2X49 STUD GR DF KD C/L2x4 NON-BEARING STUDS1st Floor226
40Ea2X422 #2 DF S4S2x4 NON-BEARING STUDS1st Floor122
50Ea2X422 #2 DF S4S2x4 NON-BEARING STUDS1st Floor112
60Ea2X410 STUD GR DF 116 1/4 KD2x4 NON-BEARING STUDS1st Floor3314
70Ea2X410 STUD GR DF 116 1/4 KD2x4 BEARING STUDS1st Floor2112
80Ea2X410 STUD GR DF 116 1/4 KD2x4 NON-BEARING STUDS2nd Floor4423
90Ea2X49 STUD GR DF KD C/L2x4 NON-BEARING STUDS1st Floor122
100Ea2X49 STUD GR DF 104 1/4 KD2x4 NON-BEARING STUDS1st Floor112
110Ea2X410 STUD GR DF 116 1/4 KD2x4 NON-BEARING STUDS1st Floor214
120Ea2X48 STUD GR DF 92 1/4 KD2x4 NON-BEARING STUDS1st Floor5633
130Lft2X610 STUD GR DF 116 1/4 KD2x6 NON-BEARING STUDS1st Floor214
140Ea2X610 STUD GR DF 116 1/4 KD3x6 BEARING STUDS1st Floor4121
150Ea2X610 STUD GR DF 116 1/4 KD3x6 BEARING STUDS1st Floor121
160Ea2X610 STUD GR DF 116 1/4 KD3x6 BEARING STUDS2nd Floor142
Thelma
</o:p>

<o:p></o:p>
After macro is executed:
Excel Workbook
ABCDEFGHI
1ThelmaCodeThelmaSumDuplicatesThelmaEaLftThelmaPieceSizeThelmaMaterialUsedThelmaStudBearingThelmaFloorThelmaSumLFTThelmaCornerChannel
2087Ea2X410 STUD GR DF 116 1/4 KD2x4 NON-BEARING STUDS1st Floor337
30121Ea2X49 STUD GR DF KD C/L2x4 NON-BEARING STUDS1st Floor226
4023Ea2X422 #2 DF S4S2x4 NON-BEARING STUDS1st Floor122
5023Ea2X422 #2 DF S4S2x4 NON-BEARING STUDS1st Floor112
6087Ea2X410 STUD GR DF 116 1/4 KD2x4 NON-BEARING STUDS1st Floor3314
7021Ea2X410 STUD GR DF 116 1/4 KD2x4 BEARING STUDS1st Floor2112
8044Ea2X410 STUD GR DF 116 1/4 KD2x4 NON-BEARING STUDS2nd Floor4423
9034Ea2X49 STUD GR DF KD C/L2x4 NON-BEARING STUDS1st Floor122
10011Ea2X49 STUD GR DF 104 1/4 KD2x4 NON-BEARING STUDS1st Floor112
11087Ea2X410 STUD GR DF 116 1/4 KD2x4 NON-BEARING STUDS1st Floor214
12056Ea2X48 STUD GR DF 92 1/4 KD2x4 NON-BEARING STUDS1st Floor5633
13021Lft2X610 STUD GR DF 116 1/4 KD2x6 NON-BEARING STUDS1st Floor214
14053Ea2X610 STUD GR DF 116 1/4 KD3x6 BEARING STUDS1st Floor4121
15053Ea2X610 STUD GR DF 116 1/4 KD3x6 BEARING STUDS1st Floor121
16014Ea2X610 STUD GR DF 116 1/4 KD3x6 BEARING STUDS2nd Floor142
Thelma


Thank you for your help
Charlie
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Charlie,
You don't need a Macro for this. Simply combine the cells into a single string in a free column J. F.e. in J2:
Code:
 =C2&D2&E2&F2&G2
then in cell B2 you put
Code:
  =sumif(J$2:J$16,J2,H$2:H$16)

Then you copy this formula all the way down. Note the $ signs.
I hope I have the order of the sumif parameters correct, If not check the help.
 
Upvote 0
Hi NateO<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
The Sheet is named Thelma and is used over and over. Right now you see 16 entries sometimes there can be 1000 entries. The information on the sheet is input with a userform by different people. Also right now you see columns A thru I, the columns go to AE and are growing. The macro I need is only a part of a larger macro I am fairly new and I can’t figure this part out. And the sheet is cleared after each use so Mexel’s formula would have to be input each time a new estimate was started which gives a chance for error. I see I made an error on my posted sheet…that I found by using Mexcel’s beautiful formula….B3 should read 34 not 121 Thanks again Mexcel. And why not???<o:p></o:p>
Thanks for taking interest NateO any input would be greatly appreciated.<o:p></o:p>
Charlie
 
Upvote 0
Charlie,
You could:
1. enter the formula on a different sheet or workbook that does not get deleted;
2. re-enter te formula with the help of VBA when needed, then read the result back to VBA.
3. Use the same formula in VBA. Using Application.WorksheetFunction.
4. program the function yourself in your VBA. Using the combining of strings like in my formula and sifting through the entire list to test for duplicates for every item in the list. You need a loop to go through all rows and for each row go through another nested loop to compare to all others in the sheet. That will be very slow compared to Excel.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,695
Members
448,979
Latest member
DET4492

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