Vlookup with date range

JangLang

New Member
Joined
May 28, 2013
Messages
5
I have three sheets. From "Invoice", I want to find the correct lookup sheet based on year, match the LookupCode, and pull the correct Price where PurchaseDate is between BeginDate and EndDate. This one has kicked my behind. Any expertise welcome!

Sheet Invoice
YearLookupCodePurchaseDatePrice
201220122230325RAMS20120715
201320122230325RAMS20130929
201220122230325RAMS20120228

<tbody>
</tbody>

Sheet 2012
YearLookupCodeBeginDateEndDatePrice
201220122230325RAMS2012010120120331100.99
201220122230325RAMS2012040120120630105.87
201220122230325RAMS2012070120121231109.12

<tbody>
</tbody>

Sheet 2013
YearLookupCodeBeginDateEndDatePrice
201320132230325RAMS2013010120130331113.25
201320132230325RAMS2013040120130630115.31
201320132230325RAMS2012370120131231111.74

<tbody>
</tbody>
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
not understanding what you want to do can you pls explain some more with desired result where you want to use formula and what ?
 
Upvote 0
Invoice

D2, control+shift+enter, not just enter:
Rich (BB code):
=INDEX(INDIRECT("'"&A2&"'!E2:E100),
  MATCH(1,IF(INDIRECT("'"&A2&"'!B2:B100)=B2,
  IF(C2>=INDIRECT("'"&A2&"'!C2:C100),
  IF(C2<=INDIRECT("'"&A2&"'!D2:D100),1))),0))
 
Upvote 0
I appreciate the help but it didn't work. The code stalls at the... MATCH(1,IF(INDIRECT("'" (emphasis on the "'" part)

I'll send you the sample sowrkbook if you want to view the error.
 
Upvote 0
Invoice

D2, control+shift+enter, not just enter:
Rich (BB code):
=INDEX(INDIRECT("'"&A2&"'!E2:E100),
  MATCH(1,IF(INDIRECT("'"&A2&"'!B2:B100)=B2,
  IF(C2>=INDIRECT("'"&A2&"'!C2:C100),
  IF(C2<=INDIRECT("'"&A2&"'!D2:D100),1))),0))

I appreciate the help but it didn't work. The code stalls at the... MATCH(1,IF(INDIRECT("'" (emphasis on the "'" part)

I'll send you the sample sowrkbook if you want to view the error.

Missing double quotes around the range specs...
Rich (BB code):
=INDEX(INDIRECT("'"&A2&"'!E2:E100"),
  MATCH(1,IF(INDIRECT("'"&A2&"'!B2:B100")=B2,
  IF(C2>=INDIRECT("'"&A2&"'!C2:C100"),
   IF(C2<=INDIRECT("'"&A2&"'!D2:D100"),1))),0))
which must be confirmed with control+shift+enter, not just enter.
 
Upvote 0
Missing double quotes around the range specs...
Rich (BB code):
=INDEX(INDIRECT("'"&A2&"'!E2:E100"),
  MATCH(1,IF(INDIRECT("'"&A2&"'!B2:B100")=B2,
  IF(C2>=INDIRECT("'"&A2&"'!C2:C100"),
   IF(C2<=INDIRECT("'"&A2&"'!D2:D100"),1))),0))
which must be confirmed with control+shift+enter, not just enter.

I updated the code and it still stalls at the same place (" ' "). ?

It works for me as is:

https://dl.dropboxusercontent.com/u/65698317/aaCondIndexMatchWithIdirect%20JangLang.xlsx
 
Upvote 0

Forum statistics

Threads
1,215,028
Messages
6,122,749
Members
449,094
Latest member
dsharae57

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