简体   繁体   English

如何根据 CELL/INDEX/MATCH 在 Excel 中对范围求和

[英]How to SUM a range in Excel based on CELL/INDEX/MATCH

I am trying to sum a range in Excel.我正在尝试在 Excel 中求和一个范围。 I want users to be able to enter a date in one cell.我希望用户能够在一个单元格中输入日期。 Then I want to sum a range based on a static starting cell location and the corresponding location based on the date they enter.然后,我想根据静态起始单元格位置和基于它们输入的日期的相应位置求和一个范围。 For example, if they enter 1/3/2021 for the report date, I want to sum the range between B2 and B4 to get $14.例如,如果他们输入 2021 年 1 月 3 日作为报告日期,我想将 B2 和 B4 之间的范围相加得到 14 美元。 I have the following formula which gives me an error.我有以下公式,这给了我一个错误。 Any ideas on how to get this formula to work as expected?关于如何让这个公式按预期工作的任何想法? Thanks for your help!谢谢你的帮助!

=SUM(B2:CELL("address",INDEX(A2:B63,MATCH(G1,A2:A63,1),2))) =SUM(B2:CELL("地址",INDEX(A2:B63,MATCH(G1,A2:A63,1),2)))

在此处输入图像描述

在此处输入图像描述

Date日期 Sales销售量 Misc Column杂项栏目 Misc Value杂项价值
1/1/2021 2021 年 1 月 1 日 $3 3 美元 Report Date报告日期 1/4/2021 2021 年 1 月 4 日
1/2/2021 2021 年 1 月 2 日 $6 6 美元 Sales Total Formula销售总额公式 =SUM(B2:CELL("address",INDEX(A2:B5,MATCH(D2,A1:A5,1)2))) =SUM(B2:CELL("地址",INDEX(A2:B5,MATCH(D2,A1:A5,1)2)))
1/3/2021 2021 年 1 月 3 日 $5 5 美元 Sales Total (expected value)销售总额(预期值) $21 21 美元
1/4/2021 2021 年 1 月 4 日 $7 7 美元 Sales Total (actual value)销售总额(实际价值) I get an error我收到一个错误

If your dates are sorted:如果您的日期已排序:

=SUMIFS(B:B,A:A,"<="&D2)

在此处输入图像描述

If not:如果不:

=SUM(B2:INDEX(B:B,MATCH(D2,A:A,0)))

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM