Excel- any formula to return last number in a column

Ebraham

Board Regular
Joined
Mar 21, 2015
Messages
215
Hi.


In sheet one. In cell b20. I want to return last number of column d of sheet2.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Try
=LOOKUP(2,1/(sheet2!D:D<>""),sheet2!D:D)
 
Upvote 0
Try
=LOOKUP(2,1/(sheet2!D:D<>""),sheet2!D:D)

Although that will work, it will have to process more than a million cells. Whether the last number happens to be in row 3 or row 1048576 is indifferent; it will still be forced to check every single cell in the column.

=INDEX(Sheet2!D:D,MATCH(9.9E+307,Sheet2!D:D))

is much less resource-heavy.

Regards
 
Last edited:
Upvote 0
thanks for that tip - noted the formula
but not working in my test sheet
 
Upvote 0
no
=INDEX(Sheet2!D:D,MATCH(9.9E+307,Sheet2!D:D))

 
Upvote 0
I assume we're talking about numbers here, since that's what the OP asked for? And not e.g. numbers formatted as text?

Can you post a small dataset for which that formula does not return the last number in the column?

Regards
 
Upvote 0
my bad - missed the numbers - so works fine
 
Upvote 0
No worries.

Actually, even if the column contains mixed datatypes and the OP wished to return the last non-blank entry, it would still be far better to use e.g.:

=INDEX(Sheet2!D:D,AGGREGATE(14,6,MATCH(CHOOSE({1,2},REPT("z",255),9.9E+307),Sheet2!D:D),1))

than your LOOKUP construction. Despite the length of the above, it will still process far, far more quickly.

Of course, if there are null strings ("") within the column which need to be ignored then this will not be sufficient.

Regards
 
Upvote 0
Actually, even if the column contains mixed datatypes and the OP wished to return the last non-blank entry, it would still be far better to use e.g.:

=INDEX(Sheet2!D:D,AGGREGATE(14,6,MATCH(CHOOSE({1,2},REPT("z",255),9.9E+307),Sheet2!D:D),1))

than your LOOKUP construction.
Provided, of course, that the user is working in XL2010, or later, as that is when the AGGREGATE function was introduced.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top