获取 excel 中该单元格的数据和总数
Get the data and total upto that cell in excel
我有一个 Excel Sheet 叫 Sheet1。在此 sheet 中,我有 12 列,如下所示:
| A | B | C | D | E | F | G | H | I | J | K | L
--+------+-----+-----+-----+-----+-----+-----+-----+-----+------+------+------
1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
--+------+-----+-----+-----+-----+-----+-----+-----+-----+------+------+------
2 | 200 | 200 | 300 | 300 | 400 | 400 | 500 | 500 | 500 | 500 | 500 | 500
现在在单元格单元格N5
:
If I Enter 4 then I should get 300.
If I Enter 12 then I should get 500.
If I Enter 1 then I should get 200.
在单元格 N6
中,我应该得到该单元格的总数。让我用一个例子来解释它:
If I enter 4 then I should get 1000, because 200+200+300+300 = 1000
If I enter 12 then I should get 4800 because 200+200+300+300+400+400+500+500+500+500+500+500 = 4800.
If I enter 1 then I should get 200,
If I enter 7 then I should get 2300, because 200+200+300+300+400+400+500 = 2300.
您可以使用 INDEX(MATCH())
对来获取单个值,然后将 SUM
中的值与范围内的第一个单元格组合以获得总计。
N5中的公式为,
=INDEX($A:$L,MATCH($M,$A:$L,0))
N6中的公式为,
=SUM(A2:INDEX($A:$L,MATCH($M,$A:$L,0)))
如果在找不到输入值时需要错误控制,请将这些与 IFERROR function 结合使用。
我有一个 Excel Sheet 叫 Sheet1。在此 sheet 中,我有 12 列,如下所示:
| A | B | C | D | E | F | G | H | I | J | K | L
--+------+-----+-----+-----+-----+-----+-----+-----+-----+------+------+------
1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
--+------+-----+-----+-----+-----+-----+-----+-----+-----+------+------+------
2 | 200 | 200 | 300 | 300 | 400 | 400 | 500 | 500 | 500 | 500 | 500 | 500
现在在单元格单元格N5
:
If I Enter 4 then I should get 300.
If I Enter 12 then I should get 500.
If I Enter 1 then I should get 200.
在单元格 N6
中,我应该得到该单元格的总数。让我用一个例子来解释它:
If I enter 4 then I should get 1000, because 200+200+300+300 = 1000
If I enter 12 then I should get 4800 because 200+200+300+300+400+400+500+500+500+500+500+500 = 4800.
If I enter 1 then I should get 200,
If I enter 7 then I should get 2300, because 200+200+300+300+400+400+500 = 2300.
您可以使用 INDEX(MATCH())
对来获取单个值,然后将 SUM
中的值与范围内的第一个单元格组合以获得总计。
N5中的公式为,
=INDEX($A:$L,MATCH($M,$A:$L,0))
N6中的公式为,
=SUM(A2:INDEX($A:$L,MATCH($M,$A:$L,0)))
如果在找不到输入值时需要错误控制,请将这些与 IFERROR function 结合使用。