Lookup last non blank cell in column excluding ""

2.5k views Asked by At

I've found this code on the site and it works great for what's its intended for:

=LOOKUP(2,1/(NOT(ISBLANK(B25:B47))),B25:B47)

However, the values in the range B25:B47 are derived from a function along the lines of B25 =IF(A25="","",A25) or =IF(ISBLANK(A25),"",A25).

The problem is the lookup function sees "" as a value and not a blank cell and doesn't exclude it from the range.

How do I exclude "" as well? Or output something as nothing (not 0) instead of "".

The reason I don't want a 0 is because my sheet gets printed and I don't want a load of zero's everywhere!

1

There are 1 answers

3
barry houdini On BEST ANSWER

Try checking the length of the cells using LEN function, then zero length data can be excluded, i.e. with

=LOOKUP(2,1/(LEN(B25:B47)>0),B25:B47)

If your data is numeric only then you could also use this formula to extract the last number in the range:

=LOOKUP(9.99E+307,B25:B47)