Search code examples
excelduplicatesmerging-data

Remove duplicates, but merge values of duplicate rows


For anything with the same commodity code and origin country, I want Excel to add up the value, mass and units columns, leaving just one of each code per country and a total of each of the other rows.

I know it can be done, but I am a bit of a VBA novice so struggling to manipulate suggestions on here to my own sheet, any help would be appreciated!

If it is possible in a pivot table instead, that would be great too, but it needs to be in line with the commodity code to put into a template.

 3917390099 - DE - 556.33 
 3917390099 - FR - 38.99

not

 3917390099
     DE           556.33
     FR           38.99

The current data looks like this:

Sample table

Thank you!


Solution

  • You can use a Pivot-Table. Adjust the Report Layout to "Show in Tabular Form" Turn off the Subtotals in the Field Settings. And if it is neccessary turn on "Repeat All Item Labels"

    enter image description here