# Function to get the last value of a column

We have a column with formulas per each row that its results can ether be blank or alphanumeric value.  We are using =LOOKUP(2,1/(1-ISBLANK(H4:H291)),H4:H291) so we can get the last value of said column.  The problem we are facing that the formula doesn't return the last value.  the included excel shows the formula and yet the last vale no matter where is at, wont be displayed at top yellow cell.

LastRowValue.xlsx
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Excel & VBA ExpertCommented:
Try one of the following formulas...

``````=LOOKUP(2,1/(H4:H11<>""),H4:H11)
``````

OR
If the values in the range are numeric...
``````=INDEX(H4:H11,MATCH(9^9,H4:H11))
``````

OR
If the values in the range are alphanumeric...
``````=INDEX(H4:H11,MATCH("zzz",H4:H11))
``````
1

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
The first one worked.

Prior closing I would like to understand it, please provide brief explanation.

Thank you
0
Excel & VBA ExpertCommented:
(H4:H11<>"") evaluates to {FALSE;TRUE;FALSE;TRUE;FALSE;FALSE;TRUE;FALSE} and False is equivalent to 0 and True is equivalent to 1.
When 1 is divided by {FALSE;TRUE;FALSE;TRUE;FALSE;FALSE;TRUE;FALSE}, it returns either #DIV/0! (divided by zero) error or 1 i.e. {#DIV/0!;1;#DIV/0!;1;#DIV/0!;#DIV/0!;1;#DIV/0!} so your formula becomes...

=LOOKUP(2,{#DIV/0!;1;#DIV/0!;1;#DIV/0!;#DIV/0!;1;#DIV/0!},H4:H11)

where 2 is lookup value, {#DIV/0!;1;#DIV/0!;1;#DIV/0!;#DIV/0!;1;#DIV/0!} is the lookup_vector and H4:H11 is the result_vector and since Lookup returns the approximate match, it picks up the last 1 (true) and returns the corresponding value from the result vector.

Hope this helps.
0
Author Commented:
Thank you
0
Excel & VBA ExpertCommented:
You're welcome!
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.