简体   繁体   English

如何在Excel中将具有相同值的多个单元格分组

[英]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. 我正在尝试在Excel中对多个单元格进行分组,以给出这三个单元格存在的总时间的最终值,例如,如果“国家/地区”为“ UK”,则“方法”为“ Method1”,“权重”为“ 400”其中的2个如在下表中所示出现2次,我想将其合并,使其仅出现一次,但是Amount列的值为“ 2”以表示它在工作表中存在多少次。 The data I am using has thousands of different and varying values. 我使用的数据具有成千上万个不同且变化的值。 I am using Microsoft Excel 2016. 我正在使用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 ) 为了以防万一,请附加我如何设置数据透视表以进行所需的操作(请注意,我的Excel使用西班牙语,但每个字段的位置必须相同,并且“ 值”部分中的操作影响字段金额必须为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. 通过单击左边距中的数字1、2或3,您可以查看/隐藏该国家/地区的小计。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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