LOOKUP next to last entry

Titian

Well-known Member
Joined
Dec 17, 2004
Messages
567
This formula operates correctly in that it returns the matching value from the concatination of cells H2&G5 in column "B" and returns the value off the same row in column "C".

Code:
=LOOKUP(2,1/(B:B=H2&G5),C:C)

Can the formula be amended to return the penultimate matching value?

Thanks in advance
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
This formula operates correctly in that it returns the matching value from the concatination of cells H2&G5 in column "B" and returns the value off the same row in column "C".


=LOOKUP(2,1/(B:B=H2&G5),C:C)


Can the formula be amended to return the penultimate matching value?

Thanks in advance
Try something like this...

With your data in the range B1:C20...

Array entered**:

=INDEX(C:C,LARGE(IF(B1:B20=H2&G5,ROW(B1:B20)),2))

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.
 
Upvote 0
Thanks Biff, that does the job.

One question, if a second occurrence is not present in the data list an error is returned, #NUM!, how's best to trap the error and return "only one"?

Thanks again.
 
Upvote 0
Thanks Biff, that does the job.

One question, if a second occurrence is not present in the data list an error is returned, #NUM!, how's best to trap the error and return "only one"?

Thanks again.
If you're using Excel 2007 or later...

Still array entered...

=IFERROR(INDEX(C:C,LARGE(IF(B1:B20=H2&G5,ROW(B1:B20)),2)),"Only One")
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,795
Members
452,943
Latest member
Newbie4296

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