Excel 对给定列号列表中的所有单元格求和的公式?

Excel formula to sum all cells that are in a list of given column numbers?

我有这样的数据

Bin 0   Bin 1   Bin 2   Bin 3   Bin 4   Bin 5   Bin 6   Bin 7
0.6967  0.6967  0.0503  0.0497  0.0971  0.0526  0.0009  0.0013

我有一个 bins 列表要求和,例如我想对 bins 2,5 和 7 求和。我将如何编写公式来对这些 bins 编号的所有单元格求和?我尝试了类似 {=SUM(OFFSET(A2,{2,5,7}))} 的方法,但我认为我没有正确使用数组公式,因为它不起作用。

你会使用 SUMIFS():

=SUM(SUMIFS(2:2,1:1,{"Bin 2","Bin 5","Bin 7"}))

如果您只想列出一个范围内的 bin 编号,那么您可以改用它:

=SUM(SUMIFS(2:2,1:1,"Bin " & I5:I7))

这需要作为数组公式输入,Ctrl-Shift-Enter。如果操作正确,那么 excel 将在公式周围放置 {}

您可以结合使用 SUM 和 VLOOKUP 来实现此目的,只需将单元格编号列表作为 VLOOKUP 的索引传递(是的,它支持列表作为索引!!)您可以尝试以下操作:

=SUM(VLOOKUP(A2, A2:M2, {2, 5, 7}, false))

{2, 5, 7}      : is the list of indexes you specify to be summed
first argument : must be the first element in the range 
second argument: is the range to look up into
result         : B2+E2+G2

并记住将这个方程用大括号括起来或按 ctrl-shift-enter 而不是 enter

将其视为数组方程