带有 OR 条件的 SUMIF [英] SUMIF with OR criteria

查看:86
本文介绍了带有 OR 条件的 SUMIF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Excel 单元格中使用 SUMIF 公式,该公式必须在给定范围内求和,而不是查找单个值,而是应该查找多个值?

How to use SUMIF formula in Excel cell that must sum over a given range and instead of finding for a single value, it should find multiple values?

为了查找单个值,我使用:

For finding a single value, I use:

=SUMIF(A4:A100;"1";B4:B100)

现在我需要总结 A 列是否包含 12,例如:

Now I need to sum over if the column A holds 1 or 2, like:

=SUMIF(A4:A100;"1" OR "2";B4:B100)

单元格 A1 将作为文本保存条件,这里是 1;2.

The cell A1 will hold the criteria as a text, here it would be 1;2.

它应该返回相同的

=SUMIF(A4:A100;"1";B4:B100) + SUMIF(A4:A100;"2";B4:B100)

但我需要一个可以采用任意数量标准(1、2、3...或更多)的公式.

but I need a formula that can take any number of criteria (1,2,3,... or more).

语法是什么?我不能在这里使用 VBA.

What's the syntax? I'm not able to use VBA here.

推荐答案

总结 1 或 2 试试这个版本

To sum for 1 or 2 try this version

=SUM(SUMIF(A4:A100;{1;2};B4:B100))

SUMIF 将返回一个包含两个结果的数组",因此您需要 SUM 将该数组相加以获得 1 和 2 的总数

SUMIF will return an "array" of two results so you need SUM to sum that array for the total for 1 and 2

您可以添加任意数量的数字 e,g,

You can add as many numbers as you like e,g,

=SUM(SUMIF(A4:A100;{1;2;3;4};B4:B100))

或在 Z1:Z10 等范围内列出的数字

or with numbers listed in a range like Z1:Z10

=SUMPRODUCT(SUMIF(A4:A100;Z1:Z10;B4:B100))

这篇关于带有 OR 条件的 SUMIF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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