Return values based on date range

Cubist

Well-known Member
Joined
Oct 5, 2023
Messages
1,908
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi,
I have a lookup table on the left and data on the right. I'm wondering what's the best way to return the values (A, B, C, D) if the date is in the range on the left. If not found, return 0.

Book1.xlsm
ABCDEF
1Begin DateEnd DateReturnDateReturn
22/1/211/31/22A5/31/19
32/1/221/31/23B6/30/19
42/1/231/31/24C7/31/19
52/1/241/31/25D8/31/19
69/30/19
710/31/19
811/30/19
912/31/19
101/31/20
112/29/20
123/31/20
134/30/20
145/31/20
156/30/20
167/31/20
178/31/20
189/30/20
1910/31/20
2011/30/20
2112/31/20
221/31/21
232/28/21
243/31/21
254/30/21
265/31/21
276/30/21
287/31/21
298/31/21
309/30/21
3110/31/21
3211/30/21
3312/31/21
341/31/22
352/28/22
363/31/22
374/30/22
385/31/22
396/30/22
407/31/22
418/31/22
429/30/22
4310/31/22
4411/30/22
4512/31/22
461/31/23
472/28/23
483/1/23
Sheet1
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Try this


Excel Formula:
=IF(
AND(E2>$A$2-1,E2<$B$2+1)=TRUE,$C$2,
IF(AND(E2>$A$3-1,E2<$B$3+1)=TRUE,$C$3,
IF(AND(E2>$A$4-1,E2<$B$4+1)=TRUE,$C$4,
IF(AND(E2>$A$5-1,E2<$B$5+1)=TRUE,$C$5,""))))


1705552566211.png
 
Upvote 0
Try:

Book1
ABCDEF
1Begin DateEnd DateReturnDateReturn
22/1/20211/31/2022A5/31/20190
32/1/20221/31/2023B6/30/20190
42/1/20231/31/2024C7/31/20190
52/1/20241/31/2025D8/31/20190
69/30/20190
710/31/20190
811/30/20190
912/31/20190
101/31/20200
112/29/20200
123/31/20200
134/30/20200
145/31/20200
156/30/20200
167/31/20200
178/31/20200
189/30/20200
1910/31/20200
2011/30/20200
2112/31/20200
221/31/20210
232/28/2021A
243/31/2021A
254/30/2021A
265/31/2021A
276/30/2021A
287/31/2021A
298/31/2021A
309/30/2021A
3110/31/2021A
3211/30/2021A
3312/31/2021A
341/31/2022A
352/28/2022B
363/31/2022B
374/30/2022B
385/31/2022B
396/30/2022B
407/31/2022B
418/31/2022B
429/30/2022B
4310/31/2022B
4411/30/2022B
4512/31/2022B
461/31/2023B
472/28/2023C
483/1/2023C
Sheet2
Cell Formulas
RangeFormula
F2:F48F2=IFERROR(VLOOKUP(E2:E48,A2:C5,3),0)
Dynamic array formulas.
 
Upvote 0
Another possible option

24 01 18.xlsm
ABCDEF
1Begin DateEnd DateReturnDateReturn
21/02/202131/01/2022A31/05/20190
31/02/202231/01/2023B30/06/20190
41/02/202331/01/2024C31/07/20190
51/02/202431/01/2025D31/08/20190
630/09/20190
731/10/20190
830/11/20190
931/12/20190
1031/01/20200
1129/02/20200
1231/03/20200
1330/04/20200
1431/05/20200
1530/06/20200
1631/07/20200
1731/08/20200
1830/09/20200
1931/10/20200
2030/11/20200
2131/12/20200
2231/01/20210
2328/02/2021A
2431/03/2021A
2530/04/2021A
2631/05/2021A
2730/06/2021A
2831/07/2021A
2931/08/2021A
3030/09/2021A
3131/10/2021A
3230/11/2021A
3331/12/2021A
3431/01/2022A
3528/02/2022B
3631/03/2022B
3730/04/2022B
3831/05/2022B
3930/06/2022B
4031/07/2022B
4131/08/2022B
4230/09/2022B
4331/10/2022B
4430/11/2022B
4531/12/2022B
4631/01/2023B
4728/02/2023C
481/03/2023C
Lookup letter
Cell Formulas
RangeFormula
F2:F48F2=XLOOKUP(E2:E48,A2:A5,C2:C5,0,-1)
Dynamic array formulas.
 
Upvote 0
Solution

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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