Lookup a value and find max date in excel
Lookup a value in A8:A14 and return max date
Array formula in C5:
How to create an array formula
- Doubleclick C5
- Paste array formula
- Press and hold Ctrl + Shift
- Press Enter
Explaining array formula in cell C5
Step 1 - Find values equal to lookup value
C3=A8:A14
becomes
"EE"={"AA";"CC";"EE";"BB";"EE";"VV";"EE"}
and returns
{FALSE;FALSE;TRUE;FALSE;TRUE;FALSE;TRUE}
Step 2 - Convert boolean values to corresponding dates
IF(C3=A8:A14, B8:B14)
becomes
IF({FALSE;FALSE;TRUE;FALSE;TRUE;FALSE;TRUE} ,B8:B14)
becomes
IF({FALSE;FALSE;TRUE;FALSE;TRUE;FALSE;TRUE} , {40152; 40156; 40323; 40068; 40149; 40312; 40195})
and returns
{FALSE;FALSE;40323;FALSE;40149;FALSE;40195}
Step 3 - Return the largest value
=MAX(IF(C3=A8:A14, B8:B14))
becomes
=MAX({FALSE;FALSE;40323;FALSE;40149;FALSE;40195})
and returns 40323 formatted as 2010-05-25.
Download excel file for this tutorial.
Lookup value and return max date.xls
(Excel 97-2003 Workbook *.xls)
Functions in this article:
IF(logical_test;[value_if:true];[value_if_false])
Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE
MAX(number1,[number2],)
Returns the largest value in a set of values. Ignores logical values and text.
Related blog posts
- Lookup min max values within a date range in excel
- Lookup two index columns using min max values and a date range as criteria
- Vlookup with 2 or more lookup criteria and return multiple matches in excel
- Lookup with multiple criteria and display multiple search results using excel formula
- Lookup a value in a list and return multiple matches in excel








January 22nd, 2010 at 6:57 pm
This is a great example. I was attempting to figure out how to get the greatest date based on a log on ID. This example fit the bill perfectly. Many thanks!!
January 24th, 2010 at 11:25 pm
Thanks for your comment!
December 27th, 2011 at 6:30 pm
Excellent example and explanation. This helped me tremendously and saved me a LOT of time. Thank you so much!
January 6th, 2012 at 1:09 pm
Brent,
Thanks for commenting!
February 1st, 2012 at 5:22 pm
Totally agree, I haven't used arrays before and this was a great intro. Thanks!
February 2nd, 2012 at 10:14 pm
JS,
thanks! I wrote an explanation.