简体   繁体   中英

How to group multiple cells with the same values in Excel

I am trying to group multiple cells in Excel to give me an end value of the total of times those three cells exist, for example, if the Country is "UK", the Method is "Method1" and Weight is "400", instead of that appearing 2 times as it does in the table below, I would like to merge it so it is there only once, but the Amount column has a value of "2" to represent how many times it is in the Sheet. The data I am using has thousands of different and varying values. I am using Microsoft Excel 2016.

Thank you.

Current Sheet:

Country   Method   Weight   Amount

USA       Method7   200       x
UK        Method1   400       x
UK        Method1   400       x
FRANCE    Method55  3994      x


Desired Sheet:

Country   Method   Weight   Amount

USA       Method7   200       1
UK        Method1   400       2
FRANCE    Method55  3994      1

This is how my original data looks like:

在此处输入图片说明

And I can resume it as you need using Pivot Tables

在此处输入图片说明

Make sure you set the Pivot Table Value Property as count when using the field Amount

Just in case it may help, I'm attaching how I set up this Pivot Table to make the operations you need (please, note my Excel is in Spanish, but position of each field must be the same, and the operation in Values section affecting field Amount must be COUNT )

在此处输入图片说明

As there is a direct link between country, method and weight, you can use subtotals for that (menu "Data", chapter "Outline", feature "Subtotals"). You configure it as:

At each change in : "Country"
Use function      : "Count"
Add subtotal to:
  Country (No)
  Method  (No)
  Weigth  (No)
  Amount  (Yes)
Replace current subtotals (Yes)
Page break between groups (No)
Summary below data        (Yes)

Your result will look as follows:

在此处输入图片说明

By clicking on the numbers 1, 2 or 3 in the left margin, you'll be able to view/hide subtotals for that country.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM