简体   繁体   English

Excel宏基于另一个单元格的通用值将两个单元格的值相加(求和)

[英]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.

相关问题 Excel宏,根据另一个单元格值复制和粘贴多个单元格? - Excel macro, to copy and paste a multiple cells based on another cell value? Excel宏,要基于另一个单元格值复制和粘贴单元格值? - Excel macro, to copy and paste a cell value based on another cell value? 使用宏将Excel 2016中另一个单元格的选定单元格值求和 - Sum slected cell value with another cell in Excel 2016 using macro Excel宏可根据单元格值将一行中的选定单元格从一张纸复制到另一张纸 - Excel Macro to copy select cells from a row from one sheet to another based upon a cell value 根据两个单元格的值更改单元格的值 - VBA Excel - Changing value of a cell based on the value of two cells - VBA Excel Excel宏-根据值将单元格从一张纸复制到另一张纸 - Excel Macro - copy cells from one sheet into another based on value 当单元格的总和达到 Excel 中另一个单元格的值时突出显示单元格 - Highlight cells when its sum reached the value on another cell in Excel excel:比较两个单元格的值,并在另一个单元格中设置值 - excel: comparing the value of two cells, and set the value in another cell Excel-根据另一个单元格值填充多个单元格 - Excel - Populate multiple cells based on another cell value Excel VBA-根据另一个单元格的值选择单元格,然后选择“自动求和”-是否可以 - Excel VBA - Select cells based on the value of another cell and then Autosum - Is it possible
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM