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
[TABLE="width: 500"]
<tbody>[TR]
[TD]Year[/TD]
[TD]LookupCode[/TD]
[TD]PurchaseDate[/TD]
[TD]Price[/TD]
[/TR]
[TR]
[TD]2012[/TD]
[TD]20122230325RAMS[/TD]
[TD]20120715[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2013[/TD]
[TD]20122230325RAMS[/TD]
[TD]20130929[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2012[/TD]
[TD]20122230325RAMS[/TD]
[TD]20120228[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Sheet 2012
[TABLE="width: 500"]
<tbody>[TR]
[TD]Year[/TD]
[TD]LookupCode[/TD]
[TD]BeginDate[/TD]
[TD]EndDate[/TD]
[TD]Price[/TD]
[/TR]
[TR]
[TD]2012[/TD]
[TD]20122230325RAMS[/TD]
[TD]20120101[/TD]
[TD]20120331[/TD]
[TD]100.99[/TD]
[/TR]
[TR]
[TD]2012[/TD]
[TD]20122230325RAMS[/TD]
[TD]20120401[/TD]
[TD]20120630[/TD]
[TD]105.87[/TD]
[/TR]
[TR]
[TD]2012[/TD]
[TD]20122230325RAMS[/TD]
[TD]20120701[/TD]
[TD]20121231[/TD]
[TD]109.12[/TD]
[/TR]
</tbody>[/TABLE]
Sheet 2013[TABLE="width: 500"]
<tbody>[TR]
[TD]Year[/TD]
[TD]LookupCode[/TD]
[TD]BeginDate[/TD]
[TD]EndDate[/TD]
[TD]Price[/TD]
[/TR]
[TR]
[TD]2013[/TD]
[TD]20132230325RAMS[/TD]
[TD]20130101[/TD]
[TD]20130331[/TD]
[TD]113.25[/TD]
[/TR]
[TR]
[TD]2013[/TD]
[TD]20132230325RAMS[/TD]
[TD]20130401[/TD]
[TD]20130630[/TD]
[TD]115.31[/TD]
[/TR]
[TR]
[TD]2013[/TD]
[TD]20132230325RAMS[/TD]
[TD]20123701[/TD]
[TD]20131231[/TD]
[TD]111.74[/TD]
[/TR]
</tbody>[/TABLE]
Sheet Invoice
[TABLE="width: 500"]
<tbody>[TR]
[TD]Year[/TD]
[TD]LookupCode[/TD]
[TD]PurchaseDate[/TD]
[TD]Price[/TD]
[/TR]
[TR]
[TD]2012[/TD]
[TD]20122230325RAMS[/TD]
[TD]20120715[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2013[/TD]
[TD]20122230325RAMS[/TD]
[TD]20130929[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2012[/TD]
[TD]20122230325RAMS[/TD]
[TD]20120228[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Sheet 2012
[TABLE="width: 500"]
<tbody>[TR]
[TD]Year[/TD]
[TD]LookupCode[/TD]
[TD]BeginDate[/TD]
[TD]EndDate[/TD]
[TD]Price[/TD]
[/TR]
[TR]
[TD]2012[/TD]
[TD]20122230325RAMS[/TD]
[TD]20120101[/TD]
[TD]20120331[/TD]
[TD]100.99[/TD]
[/TR]
[TR]
[TD]2012[/TD]
[TD]20122230325RAMS[/TD]
[TD]20120401[/TD]
[TD]20120630[/TD]
[TD]105.87[/TD]
[/TR]
[TR]
[TD]2012[/TD]
[TD]20122230325RAMS[/TD]
[TD]20120701[/TD]
[TD]20121231[/TD]
[TD]109.12[/TD]
[/TR]
</tbody>[/TABLE]
Sheet 2013[TABLE="width: 500"]
<tbody>[TR]
[TD]Year[/TD]
[TD]LookupCode[/TD]
[TD]BeginDate[/TD]
[TD]EndDate[/TD]
[TD]Price[/TD]
[/TR]
[TR]
[TD]2013[/TD]
[TD]20132230325RAMS[/TD]
[TD]20130101[/TD]
[TD]20130331[/TD]
[TD]113.25[/TD]
[/TR]
[TR]
[TD]2013[/TD]
[TD]20132230325RAMS[/TD]
[TD]20130401[/TD]
[TD]20130630[/TD]
[TD]115.31[/TD]
[/TR]
[TR]
[TD]2013[/TD]
[TD]20132230325RAMS[/TD]
[TD]20123701[/TD]
[TD]20131231[/TD]
[TD]111.74[/TD]
[/TR]
</tbody>[/TABLE]