find LAST match in column

P

Pantryman

Who knows how I can lookup the LAST match in a column?

i.e., in A1:A1000 there's 1000 names, unsorted, with multiple name
repeated.
If I want to find the last mention of 'Bob' and then get the value o
the cell next to it, how can I do that?
The first match is no problem, but I can't figure out the last.

Thanks muchly,

Marinus
 
D

Domenic

=INDEX(B:B,MAX(IF(A1:A1000="Jack",ROW(A1:A1000))))

...entered using CONTROL+SHIFT+ENTER.

Hope this helps!
 
H

Harlan Grove

Domenic said:
=INDEX(B:B,MAX(IF(A1:A1000="Jack",ROW(A1:A1000))))

..entered using CONTROL+SHIFT+ENTER.

Be more efficient to use

=LOOKUP(1,1/(A1:A100="Bob"),B1:B100)
 
D

Domenic

Harlan said:
Be more efficient to use

=LOOKUP(1,1/(A1:A100="Bob"),B1:B100)

Yes, definitely! Thanks for the reminder, Harlan!

Although, wouldn't 2 serve better as the lookup value?

For example, take the following table...

Bob a
Jack b
Jane c
Bob d
Jill e
Phil f
Bob g
Jason h

If you use...

=LOOKUP(1,1/(A1:A100="Bob"),B1:B100)

...the correct result is returned, that being "g".

However, if you use...

=LOOKUP(1,1/(A1:A8="Bob"),B1:B8)

...an incorrect result is returned, that being "d".

Using 2 as the lookup value returns the correct result regardless of
the range one uses.
 
A

Aladin Akyurek

Assuming that A1:A1000 is a formula-free range...

=LOOKUP(REPT("z",255),A1:A1000,B1:B1000)
 
G

Guest

Hi Domenic,

I just saw this correspondence and I wonder if you could explain the formula
because i do not understand how it can return the right value (even though it
does!)
For instance, how do the formula know that the input 1/A1:A1000<>"" refers
to the last cell?

Thanks
Adam

"Domenic" skrev:
 

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

Top