Combine duplicates

Damo10

Active Member
Joined
Dec 13, 2010
Messages
460
Hi,

I have a worksheet "Data" that has lots of data and some duplicates, I would like a macro that will go through all the rows looking for duplicates that match in 4 columns (B,F,I,J) if there are duplicates found then I would like a message box asking if they are to be combined. If the answer is yes then the value of column K of the first matching row is to have all the values added of the other rows and then the other rows deleted just leaving the first matching row.

Regards
 
Last edited:

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hi,

I have a worksheet "Data" that has lots of data and some duplicates, I would like a macro that will go through all the rows looking for duplicates that match in 4 columns (B,F,I,J) if there are duplicates found then I would like a message box asking if they are to be combined. If the answer is yes then the value of column K of the first matching row is to have all the values added of the other rows and then the other rows deleted just leaving the first matching row.

Regards
Do you mean to say that for row 1 if you have same values in each of columns B,F,I,J then the sum of the values are to be given in column K of row 1? If not same then leave col K blank.
 
Upvote 0
Hi,

I would only like to add the values of columns G & K (Forgot to add column G in original post) the rest of the matching rows apart from the first which has the values changed are to be deleted.

See example below

row 9 shows what the result would be and this would replace the values in row 3 and row 4 deleted. There may be more than 2 rows with matching criteria and there could be several different matches.

Excel Workbook
BCDEFGHIJK
1MachineIndexStartFinishBaseKGFlavourCodeFruit %No Bags
21100:0000:50THY100800StrawberryBAS1001510
31200:5002:10RTH2431200RaspberryBAS1012018
41502:1006:00RTH2431800RaspberryBAS1012035
52800:0006:00EDR5001500HoneyBDR453105
621506:0007:00WEW236400VanillaGHY7771710
721807:0008:00DEG670350CherryCHY1061518
8
91200:5002:10RTH2433000StrawberryBAS1012053
Sheet1

Excel 2010

Hope that makes it clearer

Regards
 
Upvote 0
I dont know on what basis u r filling the values in cols C,D,E.....
The summation part, i have shown the formula. hope it helps.
Excel Workbook
ABCDEFGHIJ
1MachineIndexStartFinishBaseKGFlavourCodeFruit %No Bags
2110:000:50THY100800StrawberryBAS1001510
3120:502:10RTH2431200RaspberryBAS1012018
4152:106:00RTH2431800RaspberryBAS1012035
5280:006:00EDR5001500HoneyBDR453105
62156:007:00WEW236400VanillaGHY7771710
72187:008:00DEG670350CherryCHY1061518
8
91300053
10275028
Sheet2
Excel 2007
Cell Formulas
RangeFormula
F9=SUMIF($A$2:$A$7,$A9,F$2:F$7)-VLOOKUP($A9,A$2:F$7,6,FALSE)
F10=SUMIF($A$2:$A$7,$A10,F$2:F$7)-VLOOKUP($A10,A$2:F$7,6,FALSE)
J9=SUMIF($A$2:$A$7,$A9,J$2:J$7)-VLOOKUP($A9,A$2:J$7,10,FALSE)
J10=SUMIF($A$2:$A$7,$A10,J$2:J$7)-VLOOKUP($A10,A$2:J$7,10,FALSE)
 
Upvote 0
Thanks for your reply.

The data is imported via VBA from 4 other workbooks and listed on this sheet, I am looking for a VBA macro that will do the combining as the ammount of data imported will change daily.

Regards
 
Upvote 0
In that case i would suggest to keep the formulas in a different sheet. The everytime u run your macro ur formula sheet will be update automatically.

You will need to change the ranges to the end of the excel sheets so that all of your data is covered.
 
Upvote 0
I would really prefer a VBA solution to this if possible as there is a lot of rows which differ in numbers per day.

Row 9 does not exist in my sheet as this is only an example of what to change the data to.

Can anyone help with this?

Regards
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,762
Members
452,940
Latest member
rootytrip

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