Excel:执行一个SUMIF,其中标准是以逗号分隔的列表 [英] Excel: Perform a SUMIF where the criteria is a comma-delimited list

查看:164
本文介绍了Excel:执行一个SUMIF,其中标准是以逗号分隔的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的第一个Excel工作表中,我有一张ID和值表:

  ID VALUE 
1 30
2 35
3 14
4 92

在我的第二个工作表中,我将在一列中提供逗号分隔的ID列表,在第二列中,我想要计算这些ID值的总和,如下所示:

  ID SUM 
1,2 65
2,3,4 141
3 14
/ pre>

如何编写第二个工作表的SUM列的公式?如果可能,我想避免VBA。

解决方案

假设,对于给出的示例表:



1)您的源表格在 Sheet1!A1:B5 (带有第1行的标题)



2)您的结果表格在 Sheet2!A1:B4 (带行头1)



3)结果表中列A中的条目的分隔符只有一个逗号



然后在 Sheet2!B2 数组公式 **:



= SUM (ISNUMBER(FIND( &安培; Sheet 1中A $ 2:!甲$ 5&安培;, , &安培; A2&安培;,)),工作表Sheet B $ 2:B 5 $))



复制到 B4



请问



**数组公式的输入方式与'standard'公式相同。而不是按ENTER键,您首先按住CTRL和SHIFT,然后只按ENTER。如果您已经正确完成,您会注意到Excel在公式周围放置大括号{}(尽管不要手动插入这些)。


In my first Excel worksheet, I have a table of IDs and Values:

ID  VALUE
1   30
2   35
3   14
4   92

In my second worksheet, I will provide a comma-delimited list of IDs in one column, and in the second column, I'd like the calculated sum of those IDs' values, like this:

IDs     SUM
1,2     65
2,3,4   141
3       14

How would I write the formula for the SUM column of the second worksheet? I'd like to avoid VBA if possible.

解决方案

Assuming that, for the example tables you give:

1) Your source table is in the range Sheet1!A1:B5 (with headers in row 1)

2) Your results table is in the range Sheet2!A1:B4 (with headers in row 1)

3) The delimiter for the entries in column A of the results table is only ever a single comma

then, in Sheet2!B2, array formula**:

=SUM(IF(ISNUMBER(FIND(","&Sheet1!A$2:A$5&",",","&A2&",")),Sheet1!B$2:B$5))

Copy down to B4.

Regards

**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

这篇关于Excel:执行一个SUMIF,其中标准是以逗号分隔的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆