Nested VLOOKUP in an IF statement

jlcochran38

New Member
Joined
Jun 11, 2016
Messages
9
I need some help with a formula (see tables below). What I need is for the Reference ID in the first table to lookup the Reference ID in the second table, and if the date range for that Reference ID in the first table falls inside one the date ranges within the second table, the price needs to show.

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Reference ID[/TD]
[TD]Product Name[/TD]
[TD]Start Date[/TD]
[TD]End Date[/TD]
[TD]Price[/TD]
[/TR]
[TR]
[TD]00123[/TD]
[TD]Product ABCD[/TD]
[TD]10/1/2016[/TD]
[TD]10/31/2016[/TD]
[TD]$59.00[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Reference ID[/TD]
[TD]Product Name[/TD]
[TD]Price[/TD]
[TD]Start Date[/TD]
[TD]End Date[/TD]
[/TR]
[TR]
[TD]00123[/TD]
[TD]Product ABCD[/TD]
[TD]182.00[/TD]
[TD]7/1/2018[/TD]
[TD]6/30/2019[/TD]
[/TR]
[TR]
[TD]00124[/TD]
[TD]Product EFGH[/TD]
[TD]75.00[/TD]
[TD]7/1/2015[/TD]
[TD]6/30/2017[/TD]
[/TR]
[TR]
[TD]00124[/TD]
[TD]Product EFGH[/TD]
[TD]64.00[/TD]
[TD]7/1/2017[/TD]
[TD]6/30/2018[/TD]
[/TR]
[TR]
[TD]00124[/TD]
[TD]Product EFGH[/TD]
[TD]87.00[/TD]
[TD]7/1/2018[/TD]
[TD]6/30/2019[/TD]
[/TR]
[TR]
[TD]00123[/TD]
[TD]Product ABCD[/TD]
[TD]59.00[/TD]
[TD]7/1/2015[/TD]
[TD]6/30/2017[/TD]
[/TR]
[TR]
[TD]00123[/TD]
[TD]Product ABCD[/TD]
[TD]24.00[/TD]
[TD]7/1/2017[/TD]
[TD]6/30/2018[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
If you're sure you won't have multiple prices in the same range, you can use a SUMIFS:

ABCDEFG
Reference IDProduct NameStart DateEnd DatePrice
Product ABCD
Reference IDProduct NamePriceStart DateEnd Date
Product ABCD
Product EFGH
Product EFGH
Product EFGH
Product ABCD
Product ABCD

<tbody>
[TD="align: center"]1[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]2[/TD]
[TD="align: right"]123[/TD]

[TD="align: right"]10/1/2016[/TD]
[TD="align: right"]10/31/2016[/TD]
[TD="align: right"]$59.00[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]3[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]4[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]5[/TD]
[TD="align: right"]123[/TD]

[TD="align: right"]182[/TD]
[TD="align: right"]7/1/2018[/TD]
[TD="align: right"]6/30/2019[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]6[/TD]
[TD="align: right"]124[/TD]

[TD="align: right"]75[/TD]
[TD="align: right"]7/1/2015[/TD]
[TD="align: right"]6/30/2017[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]7[/TD]
[TD="align: right"]124[/TD]

[TD="align: right"]64[/TD]
[TD="align: right"]7/1/2017[/TD]
[TD="align: right"]6/30/2018[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]8[/TD]
[TD="align: right"]124[/TD]

[TD="align: right"]87[/TD]
[TD="align: right"]7/1/2018[/TD]
[TD="align: right"]6/30/2019[/TD]
[TD="align: right"][/TD]

[TD="align: center"]9[/TD]
[TD="align: right"]123[/TD]

[TD="align: right"]59[/TD]
[TD="align: right"]7/1/2015[/TD]
[TD="align: right"]6/30/2017[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]10[/TD]
[TD="align: right"]123[/TD]

[TD="align: right"]24[/TD]
[TD="align: right"]7/1/2017[/TD]
[TD="align: right"]6/30/2018[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]11[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

</tbody>
Sheet21

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]E2[/TH]
[TD="align: left"]=SUMIFS($C$5:$C$10,$A$5:$A$10,A2,$D$5:$D$10,"<="&C2,$E$5:$E$10,">="&D2)[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Your formula works fine, but when I try to transcribe it into my spreadsheet (changing the reference locations) it doesn't seem to work anymore.

=SUMIFS('Contract Pricing All'!$C$2:$C$7,'Contract Pricing All'!$A$2:$A$7,Recovered_Sheet1!A2,'Contract Pricing All'!$D$2:$D$7,"<="&Recovered_Sheet1!C2,'Contract Pricing All'!$E$2:$E$7,">="&Recovered_Sheet1!D2)
 
Upvote 0
When you say "doesn't seem to work" what do you mean? Returns an error, or zero value, or wrong value?

I renamed the sheets in my test workbook to match your formula, then pasted it exactly as you wrote it, and I got the right response. Just make sure that the ranges are correct, and the sheet names are too (spaces vs. underlines).
 
Upvote 0
I'm not sure what else to tell you. It works fine in my workbook, even using the formula you provided in post 3. Make sure that your ranges are correct, make sure that the dates are actual dates, not text, and try again.
 
Upvote 0
It looks like the latter is the issue. This is not my spreadsheet, but whoever used it last used some jacked up formatting on the dates...some even having spacing. That's probably the issue.
 
Upvote 0

Forum statistics

Threads
1,223,710
Messages
6,174,019
Members
452,542
Latest member
Bricklin

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