Merge duplicates Batches based on column contains the same price

MKLAQ

Active Member
Joined
Jan 30, 2021
Messages
428
Office Version
  1. 2016
Platform
  1. Windows
Hello,
I have duplicates BATCH in column B ,contains many prices in column G . if the duplicates BATCH contains the same price then merge for column F , otherwise don't merge.
when merge duplicates batch should be based on column B .
the batches could be 2000 and repeated batches could reach 6000 rows.
I would merge in the same sheet
mkk ‫‬.xlsx
ABCDEFGH
8ITEMBATCHGOODSTYPEMODELIMPORTPRICETOTAL
91CCR-001 CR CCR-1 2010BMW380.0012,000.004,560,000.00
102CCR-001 CR CCR-1 2010BMW120.0012,000.001,440,000.00
113CCR-002TR CCB-3 TCR 1-TT2009 MER120.0011,000.001,320,000.00
124CCR-003CCR-2 FI 2012TIGUAN120.0012,500.001,500,000.00
135CCR-003CCR-2 FI 2012TIGUAN100.0012,300.001,230,000.00
146CCR-004TR CCB-3 TMIR 1-TT2009 MER101.004,400.00444,400.00
157CCR-004TR CCB-3 TMIR 1-TT2009 MER80.004,400.00352,000.00
16TOTAL10,846,400.00
CA
Cell Formulas
RangeFormula
H9:H15H9=F9*G9
H16H16=SUM(H9:H15)


should be like this

mkk ‫‬.xlsx
ABCDEFGH
8ITEMBATCHGOODSTYPEMODELIMPORTPRICETOTAL
91CCR-001 CR CCR-1 2010BMW500.0012,000.006,000,000.00
102CCR-002TR CCB-3 TCR 1-TT2009 MER120.0011,000.001,320,000.00
113CCR-003CCR-2 FI 2012TIGUAN120.0012,500.001,500,000.00
124CCR-003CCR-2 FI 2012TIGUAN100.0012,300.001,230,000.00
135CCR-004TR CCB-3 TMIR 1-TT2009 MER181.004,400.00796,400.00
14TOTAL10,846,400.00
CA
Cell Formulas
RangeFormula
H9:H13H9=F9*G9
H14H14=SUM(H9:H13)
 
Last edited:

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
1725591859116.png
you could use a pivot table with the following setting to provide this. See if that helps.
 
Upvote 0
An alternative is with Power Query

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Removed Columns" = Table.RemoveColumns(Source,{"ITEM"}),
    #"Grouped Rows" = Table.Group(#"Removed Columns", {"BATCH", "GOODS", "TYPE", "MODEL", "PRICE"}, {{"Import", each List.Sum([IMPORT]), type number}, {"Total", each List.Sum([TOTAL]), type number}}),
    #"Added Index" = Table.AddIndexColumn(#"Grouped Rows", "Index", 1, 1, Int64.Type),
    #"Reordered Columns" = Table.ReorderColumns(#"Added Index",{"Index", "BATCH", "GOODS", "TYPE", "MODEL", "PRICE", "Import", "Total"})
in
    #"Reordered Columns"
 
Upvote 0
I don't prefer this way, sorry .
If it's by vba will be ok for me.
 
Upvote 0
@alansidman
by the way gives error
VBA Code:
= Table.AddIndexColumn(#"Grouped Rows", "Index", 1, 1, Int64.Type)
 
Upvote 0
What is the error message. Can't help diagnose the unknown.
 
Upvote 0
here is error
: 5 arguments were passed to a function that expects between 2 and 4.
Details:
Pattern=
Arguments=List
 
Upvote 0
Did you amend the Mcode in any manner? There are only four arguments in that line of code. Make sure that there is a comma after the last closed parens.

Here is my copy of your worksheet.

 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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