How do I vlookup a date to match a date range (period)?

gkisystems

Board Regular
Joined
Apr 20, 2012
Messages
76
On my first spreadsheet within a workbook, I have some data that looks like this:


A B C D E F G...
Year Period Week Ended MiscData1 MiscData2 MiscData3 Etc
2008 2/9/2008 abc efg hij klm
2008 3/15/2008 abc efg hij klm
2009 5/16/2009 abc efg hij klm
2010 9/18/2010 abc efg hij klm


On another spreadsheet within the same workbook, I have my fiscal period calendar that looks like this:


A B C D E
Year Month Beginning End Period
2008 02 2/1/2008 3/1/2008 2008.02
2008 03 3/2/2008 3/29/2008 2008.03
2009 05 4/26/2009 5/30/2009 2009.05
2010 09 9/5/2010 10/02/2010 2010.09


As you can see, my fiscal calendar is NOT a normal calendar month. For example, October 2nd 2010 is considered to be September 2010 - not October.


On the first spreadsheet in column B (Period), how do I use a VLOOKUP formula (or something similar) to go look at my accounting calendar Beginning & End Dates to see what period the date in column C (Week Ended) should fall into?
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
This is on one sheet for illustration...

<br />
Book1
ABCDEFG
1YearPeriodWeek EndedMiscData1MiscData2MiscData3Etc
220082008.022/9/2008abcefghijklm
320082008.033/15/2008abcefghijklm
420092009.055/16/2009abcefghijklm
520102010.099/18/2010abcefghijklm
6
7YearMonthBeginningEndPeriod
82008022/1/20083/1/20082008.02
92008033/2/20083/29/20082008.03
102009054/26/20095/30/20092009.05
112010099/5/201010/2/20102010.09
Sheet1
Cell Formulas
RangeFormula
B2{=INDEX($E$8:$E$11,MATCH(1,(C2>=$C$8:$C$11)*(C2<=$D$8:$D$11),0))}
B3{=INDEX($E$8:$E$11,MATCH(1,(C3>=$C$8:$C$11)*(C3<=$D$8:$D$11),0))}
B4{=INDEX($E$8:$E$11,MATCH(1,(C4>=$C$8:$C$11)*(C4<=$D$8:$D$11),0))}
B5{=INDEX($E$8:$E$11,MATCH(1,(C5>=$C$8:$C$11)*(C5<=$D$8:$D$11),0))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
This formula actually works in theory, but not in practice because I have 100,000+ rows of data and it is not able to handle the calculation/processing. Is there a simpler formula that would work?

Yours:
={INDEX('Accounting Calendar'!$E:$E,MATCH(1,(C3>='Accounting Calendar'!$C:$C)*(C3<='Accounting Calendar'!$D:$D),0))}

Potential Alternative?
=VLOOKUP(C2,'Accounting Calendar'!$C:$E,3,TRUE)

In the alternative formula, I'm just doing a lookup at the beginning date...but I'm not sure if this is an iron clad way of doing it.

Also - how did you paste in the image of the spreadsheet to this forum? I would like to know - that's pretty cool!
 
Upvote 0
This formula actually works in theory, but not in practice because I have 100,000+ rows of data and it is not able to handle the calculation/processing. Is there a simpler formula that would work?

Yours:
={INDEX('Accounting Calendar'!$E:$E,MATCH(1,(C3>='Accounting Calendar'!$C:$C)*(C3<='Accounting Calendar'!$D:$D),0))}

Potential Alternative?
=VLOOKUP(C2,'Accounting Calendar'!$C:$E,3,TRUE)

In the alternative formula, I'm just doing a lookup at the beginning date...but I'm not sure if this is an iron clad way of doing it.

Also - how did you paste in the image of the spreadsheet to this forum? I would like to know - that's pretty cool!
Don't use the entire columns as range references, use the specific range.

Still array entered.

=INDEX('Accounting Calendar'!$E$2:$E$100000,MATCH(1,IF(C3>='Accounting Calendar'!$C$2:$C$100000,IF(C3<='Accounting Calendar'!$D$2:$D$100000,1)),0))

The nested IF is a bit more efficient compared to using array multiplication when calculating over large ranges.
 
Upvote 0
If your period ranges do not overlap each other and there is no gap between the end of a period and beginning of the next, then a simple VLOOKUP would always give the the correct result
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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