[英]How to sum over criteria in Excel?
Let's say I have a table of First/Last names and Salaries.I want to compute, for every last name, the sum of the salaries of people with that name.假设我有一个名字/姓氏和薪水表。我想计算每个姓氏的人的薪水总和。
I know how to do that for each name individually using SUMIF, but I was wondering if there is a quick function to produce a table of Last names and Salary sums?我知道如何使用 SUMIF 为每个姓名单独执行此操作,但我想知道是否有一个快速功能可以生成姓氏和工资总额的表格?
Another option would be using a pivot table.另一种选择是使用数据透视表。
Last Name
and Salary
columnsLast Name
和Salary
列Let's support you have the salary sheet in sheet1 as below,让我们支持您在 sheet1 中的工资表如下,
copy column last name value to sheet2.column A, remove duplicate, add a new column as Salary Sum in column B, input a formula as =SUMIF(Sheet1!B:B,Sheet2!A2,Sheet1!C:C) and drop down to all rows, then you can got a salary sum table as below,将列姓氏值复制到 sheet2.column A,删除重复项,在 B 列中添加一个新列作为 Salary Sum,输入公式为 =SUMIF(Sheet1!B:B,Sheet2!A2,Sheet1!C:C) 并删除到所有行,然后你可以得到一个工资总额表,如下所示,
of course, if the first name/last name is dynamic and unexpected, it would doesn't work.当然,如果名字/姓氏是动态的和意料之外的,它就行不通。 you can drop a button and bind a VBA code to handle it.
您可以删除一个按钮并绑定一个 VBA 代码来处理它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.