[英]Excel macro to add up (sum) the value of two cells based on the common value of another cell
I have a Excel sheet with data like this: 我有一个包含这样的数据的Excel工作表:
DNIS _ _ _ _ _ Numbers
442890512221, 10
442890512221, 4
442890512222, 7
442890512222, 5
442890512223, 2
442890512224, 14
442890512224, 13
I'm looking for a Macro that can add up the two number values (2nd column) if the value in the first column is equal and place that total in the third column and then to delete the second row. 我正在寻找一个宏,如果第一列中的值相等,则可以将两个数字值(第二列)相加,然后将该总数放在第三列中,然后删除第二行。
The issue is that there not always are 2 rows and by deleting a second row the pointer for a loop keeps changing. 问题在于,并非总是有2行,并且通过删除第二行,循环的指针不断变化。
This is the output I am looking for: 这是我正在寻找的输出:
DNIS _ _ _ _ , Numbers
442890512221, 14
442890512222, 12
442890512223, 2
442890512224, 27
Is there a smart way of doing this? 有这样做的聪明方法吗?
You can create a Pivote table using your data. 您可以使用数据创建数据透视表 。
Only you need select on the menu the option Insert - Pivote Table and select the data. 仅您需要在菜单上选择选项插入-数据透视表,然后选择数据。 After you selection of data in the assistant select first column as Row Field and the second as Data Item. 在助手中选择数据后,选择第一列作为“行字段”,第二列作为“数据项”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.