Return Most Right Value

AntNMC1

New Member
Joined
Sep 20, 2012
Messages
14
Below is a simple table. I would like to know of a formula that will look for the latest date within a row, taking into consideration of matching dates, and return the farthest right header.

DatesHD1HD2HD3HD4
1st1/1/2018 1/2/20181/2/20181/2/2018
2nd2/5/2018 2/5/2018
3rd1/15/2018 1/16/2018 1/16/2018
4th2/26/20182/26/2018

<colgroup><col><col span="4"></colgroup><tbody>
</tbody>

Thus, column next to HD4 should look like this:
FORMULA
HD4
HD2
HD3
HD2

Thank you!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
With your posted data in A1:E5, this formula returns the header of the last referenced date
Code:
F2: =LOOKUP(99^99,B2:E2,$B$1:$E$1)
Copy that formula down through F5

Is that something you can work with?
 
Upvote 0
Ron,

Thank you. A follow-up question: what does the 99^99 mean? Out of the formula you provided, I do not how to understand this part.

Thank you
 
Upvote 0
The LOOKUP function has a neat feature (flaw?) that can be exploited.
If your search number is larger than any value in the list....the lookup function returns the LAST numeric value in the list.
As long as the search number is larger than any possible value the correct value will be returned. I used 99^99 because it's so easy to type. Does that help?
 
Upvote 0
Here is another formula that would work. I am not sure if it would be better than Ron's formula as it involves two function calls instead of one (INDEX is a very fast function though), but given that caveat...

=INDEX(B$1:E$1,,COUNT(B2:E2))
 
Upvote 0
Here is another formula that would work. I am not sure if it would be better than Ron's formula as it involves two function calls instead of one (INDEX is a very fast function though), but given that caveat...

=INDEX(B$1:E$1,,COUNT(B2:E2))

In case of an empy cell in-between two numbers, this will flounder and it's never faster than:

=LOOKUP(9.99999999999999E+307,B2:E2,$B$1:$E$1)

when both apply. That big number is there, not because I have insensitive fingers.
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,955
Latest member
BatCoder

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