简体   繁体   English

代码以找到excel列中连续非空单元格的总和,直到出现空单元格?

[英]code to find the sum of continuous non-empty cells in a column in excel till the empty cell occurs?

在此处输入图片说明

In B1 I want to sum all the cells of first column till the empty cell occurs. 在B1中,我想对第一列的所有单元格求和,直到出现空单元格。

Use this: 用这个:

=SUM(A1:INDEX(A:A,MATCH(1E+99,A:A)))

The INDEX/MATCH formula finds the last cell that has a numeric value and sets that as the end of the Range in the SUM() formula. INDEX / MATCH公式查找具有数字值的最后一个单元格,并将其设置为SUM()公式中Range的结尾。

But ultimately if you want to sum every number in Column A then a simple Sum of the whole column will work: 但是最终,如果您想对A列中的每个数字求和,则可以对整个列进行简单的求和:

=SUM(A:A)

The SUM() Function ignores text and blank cells. SUM()函数将忽略文本和空白单元格。

If what is wanted is to sum till the first blank cell and there is data after that then use this instead: 如果想要求和直到第一个空白单元格,然后有数据,则改为使用:

=SUM(A1:INDEX(A:A,MATCH(TRUE,INDEX(A:A="",0),0)))

在此处输入图片说明

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

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