2

我正在使用 excel 2010 并希望使用 IF 语句来添加具有字母和数字的多个列。我已经把所有的编码都写进去了,这样当每个条件之一出现时,它们的总和是正确的。

我遇到的问题是是否有多个相同的条件。

例如,我使用的 IF 语句是:=IF(ISNA(MATCH("1P",C7:CO7,0)),0,1)+IF(ISNA(MATCH("2P",C7:CO7,0)),0,2)等等。

显然,在 C7 和 CO7 单元格之间有许多单元格,如果一个以上的单元格中有 1P 或 2P,则不会添加额外的单元格,而只会添加一个。如何让我的公式识别多个单元格中的条件?

谢谢

4

2 回答 2

1

=COUNTIF(C7:CO7,"1P")+2*COUNTIF(C7:CO7,"2P")应该会给你你需要的答案

编辑:固定公式 - 感谢@Andy

于 2012-06-01T20:09:11.063 回答
0

If you are interested in a flexible approach that allows for an arbitrary number of match values and multipliers, you could try this.

Make a little table somewhere of Match Values and corresponding Multipliers and use this array formula:

=SUM(IF($C$7:$CO$7=$A$2:$A$5,$B$2:$B$5,0))

Commit the array formula by pressing Ctrl+Shift+Enter.

enter image description here

Note my screen shot truncates the data range. 14 is the correct answer for the data I entered.

于 2012-06-01T21:16:48.553 回答