简体   繁体   English

范围中最后使用的单元格-Excel 2013

[英]Last used cell in a range - excel 2013

Does anybody here knows how to find out what is the last used cell in excel without using vba but only using IF statement in formula bar? 这里有人知道如何在不使用vb​​a而是仅在公式栏中使用IF语句的情况下找出excel中最后使用的单元格吗? Let's say for example, in cell AA I want to identify what is the last cell with a value and then add all the values on a certain range. 比方说,例如,在cell AA我想确定最后一个具有值的单元格,然后将所有值添加到某个范围内。 What should i do? 我该怎么办?

To find last used row index in range A:A 查找范围A:A最后使用的行索引

=LOOKUP(2,1/(NOT(ISBLANK(A:A))),ROW(A:A))

and to add all numbers from, eg A2 to A(last used row index) : 并将所有数字从A2加到A(last used row index)

=SUM(A2:INDEX(A:A,LOOKUP(2,1/(NOT(ISBLANK(A:A))),ROW(A:A))))

You can do this using an array formula also: 您还可以使用数组公式执行此操作:

=MAX(ROW(A:A)*(A:A<>""))    

Confirm this formula using Ctrl + Shift + Enter . 使用Ctrl + Shift + Enter确认此公式。

And to get sum of the range use: 并获得范围的总和,请使用:

=SUM(A1:INDEX(A:A,MAX(ROW(A:A)*(A:A<>""))))

Again this is an array formula. 同样,这是一个数组公式。

IF , and that is a mighty big IF, your data contains no blank cells, you could use: IF ,那是一个很大的IF,您的数据不包含空白单元格,您可以使用:

=COUNTA(A:A)

If you have header rows, then you need to subtract the number of non blank header rows. 如果您有标题行,则需要减去非空白标题行的数量。

IF you have data in the cells below you data that you are looking at counting then you need to subtract those too! 如果您在下面的单元格中有要查看的数据,那么您也需要减去这些数据!

SO, if all that is true then your COUNTA(A:A) will return the number of used cells which you could then turn around and use to provide a range to sum over. 因此,如果所有情况都成立,那么您的COUNTA(A:A)将返回已使用的单元格数量,然后您可以将其转过来用于提供求和范围。 Lets say you wanted to sum over Column C for equal rows then you could use: 假设您想对C列求和以获得相等的行,则可以使用:

=SUM(OFFSET($C$1,Number of headerrows,0,COUNTA(A:A)-non blank Header rows,1)

If you knew the range you wanted to sum over was D16 to the last counted row in A which we are assuming is greater than 16 but might only be D16:D18, we could do something like: 如果您知道要求和的范围是D16到A的最后一个计数行(我们假设该行大于16,但可能只是D16:D18),则可以执行以下操作:

=SUM(D16:INDEX(D:D,COUNTA(A:A)+Blank Header Rows))

But more importantly if you are just trying to sum a range where you just want the sum of non blank cells, you could use: 但更重要的是,如果您只想求和一个只希望非空白单元格之和的范围,则可以使用:

=SUMIF(A:A,"<>""",C:C)

Where C has the values you are adding C具有您要添加的值

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

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