Function to find value in cell

  • Thread starter Thread starter medwards
  • Start date Start date
M

medwards

Is there a function or a formula out there that will return the value of
the last non-blank cell in a column?
 
If you just want the last value in the column, regardless of whether or not you have any blanks in
your data, then the following will both do it:-

=LOOKUP(9.99999999999999E+307,A:A)

=INDIRECT("A"&SUMPRODUCT(MAX((ROW(A1:A1000))*(A1:A1000<>""))))
 
= OFFSET(A1,COUNTA(A:A)-1,0)

or if there are blanks within the nonblanks

=INDEX(A:A,MAX((A1:A1000<>"")*ROW(INDIRECT("1:1000"))))

the latter entered with ctrl + shift & enter
 
=LOOKUP(REPT("z",255),A:A)

if A is text or one is interested in the last text value.

If A might house any value, including logicals and/or error values, a
different (expensive) formula is needed.
 
Harlan Grove said:
...

LOOKUP(CHAR(255),A:A) would be more robust.

It fails on...

{"dra";"fra";"";"z";"zzz";"zodiac"}

where "" stands for a formula-generated blank.
 
It fails on...

{"dra";"fra";"";"z";"zzz";"zodiac"}

You're right. I was just assuming that text would work the same way as numbers,
but it appears LOOKUP with text values uses some sort of collation sequence that
includes only char codes between 32 and 126 and makes z come last.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top