Q:

Excel - lookup value based on multiple criteria - nearest date

I'm having an issue with extracting data from a range - I feel this should be able to be solved via an index/match combination but I haven't been able to make it work so far.
The range from which I will be extracting the data is structured as follows:
ID  date    User
1   01/01/2000  BA
1   04/01/2002  JI
1   01/11/2001  PK
2   03/03/2004  DT
2   03/05/2008  BI
2   04/06/2002  KW
3   02/12/2007  NK
3   06/09/2005  LW
3   01/08/2005  DH

I am trying to match a specific ID with col A and date with the the nearest date (up to but not greater than) in col B to extract the User details. For example, if I have ID = 1, date = 01/12/2001 - this should return a User value of PK.
I have tried combining this formula: =MIN(IF(A1:B6>E1,A1:B6)) with index(match * match) to use the ID and date as multiple criteria but I keep getting a #N/A error.
This formula will need to be applied to approx. 1,000 rows and the lookup range is approx. 65,000 rows.
Any suggestions would be much appreciated.
Cheers, Ant

A:

IF you can sort on the first two columns then this normal formula will work:
=VLOOKUP(E2,INDEX(B:C,MATCH(D2,A:A,0),0):INDEX(B:C,MATCH(D2,A:A,0)+COUNTIF(A:A,D2)-1,0),2,TRUE)

It will create a smaller range for the Vlookup to search. That smaller data set will include only the dates and users with the correct ID.
Again this only works if the data is sorted.  If not it will return incorrect values.

