简体   繁体   中英

VLOOKUP between two dates

I 'd like to lookup in which period a date falls. Every period has its onwn name.

In my first sheet I have a list of dates:

4/03/2019
15/01/2019
15/01/2019
20/02/2019
11/02/2019
11/02/2019

In an other sheet I have the name with the corresponsing start and end date:

NAME  START        END   
A1    12/01/2019   22/01/2019
A2    23/01/2019   8/02/2019
B     9/02/2019    13/02/2019
C1    14/02/2019   1/03/2019
C2    2/03/2019    5/03/2019
C3    6/03/2019    15/03/2019

I would like to have the following result

4/03/2019    C2
15/01/2019   A1
15/01/2019   A1
20/02/2019   C1
11/02/2019   B
11/02/2019   B

Use INDEX/MATCH Like this:

=INDEX(E:E,MATCH(A1,F:F))

在此处输入图片说明

You can try this:

I suppose that your dates are in a sheet named "dates" 在此处输入图片说明

And you have your data in other Sheet

在此处输入图片说明

You can easly get your result with the following formula:

=INDEX(Sheet12!A:C,MATCH(dates!A2,Sheet12!B:B,1),1)

在此处输入图片说明

I hope this helps!!!

Are the date ranges set to expand further beyond a static list or are they set. Because if they are set i would be tempted to do a nested IF statement. I can explain if this is the case.

IF("date cell"<=latest date,code,If("date cell"<= next latest, If( repeat until happy

You don't even need the end date, as your dates are increasing

=VLOOKUP(D1,$A$1:$B$6,2,TRUE)

where D1 is the date you're matching A is the start date and B your codes

What about using INDEX & MATCH? Example below:

[Assuming your first set of data is in column A, and the formula would be in column B on Sheet1, and your second table is columns A:C in Sheet2. So the example in your third table would have "C2" in column B]

Note: You'll need to use Ctrl+Shift+Enter to enter as an array formula.

=INDEX(Sheet2!$A$2:$A$7,MATCH($A2,IF($A2>=Sheet2!$B$2:$B$7,IF($A2<=Sheet2!$C$2:$C$7,$A2)),0))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM