简体   繁体   中英

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? 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. What should i do?

To find last used row index in range 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) :

=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 .

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:

=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. Lets say you wanted to sum over Column C for equal rows then you could use:

=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:

=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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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