How to use SUMIFS function for summing values if criteria range exists in a range?

允我心安 提交于 2019-12-25 02:34:59

问题


My data:

A   B    C
a   3    d
b   1    a
c   8    e
d   5    

I want to use SUMIFS function, sum range is B1:B4, if the corresponding value in column A exists in column C, sum the values in column B, in this case the sum will be 3 + 5 = 8 I tried =SUMIFS(B1:B4,A1:A4, COUNTIF($C$1:$C$3,A1) but I get zero.


回答1:


=SUMPRODUCT(SUMIF(A1:A4,C1:C3,B1:B4))

Link for further reading: COUNTIFS: Multiple “OR” Criteria For One Or Two Criteria_Ranges




回答2:


What you want is this:

=SUMIFS(B1:B4,A1:A4,A1)

Edit:

I know you asked for a sumif, but that doesn't want to work, entering the below as an array formula (CTRL+SHIFT+ENTER) does the trick.

=SUMPRODUCT(B1:B4,(IFERROR(MATCH(A1:A4,C1:C4,0),0)>0)*1)


来源:https://stackoverflow.com/questions/25805571/how-to-use-sumifs-function-for-summing-values-if-criteria-range-exists-in-a-rang

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!