using vlookup to lookup a date within multiple date ranges

fedebrin

New Member
Joined
Jan 3, 2013
Messages
10
Hello,

I am trying to extract a value from a list that has a data range and a parameter (ie color)

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]1-Jan-19[/TD]
[TD]28-Feb-19[/TD]
[TD]Red[/TD]
[TD]Value 1[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]1-Mar-19[/TD]
[TD]31-Mar-19[/TD]
[TD]Red[/TD]
[TD]Value 2[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]1-Jan-19[/TD]
[TD]31-Mar-19[/TD]
[TD]Blue[/TD]
[TD]Value 3[/TD]
[/TR]
</tbody>[/TABLE]

Considering I am entering the color under cell F6 and the date under cell G6, I am using the following formula but not getting the correct answer:

{=INDEX($D$1:$D$3,MATCH(1,IF(G6>=$A$1:$A$3,IF(G6<=$B$1:$B$3,IF(F6=$C$1:$C$3,1)),0)))}


Your help is really appreciated!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try:

Code:
=INDEX($D$1:$D$3,MATCH(1,IF(G6>=$A$1:$A$3,IF(G6<=$B$1:$B$3,IF(F6=$C$1:$C$3,1))[COLOR=#ff0000]),0[/COLOR]))
Excel Workbook
ABCDEFG
11-Jan-1928-Feb-19RedValue 1
21-Mar-1931-Mar-19RedValue 2
31-Jan-1931-Mar-19BlueValue 3Value 3
4
5
6blue1/5/2019
Sheet
 
Upvote 0
You're welcome. Thanks for the feedback.
If you have Excel 2010 or later you could also use the formula below that dosn't require CTRL-SHIFT-ENTER. Just ENTER.
Excel Workbook
ABCDEFG
11-Jan-1928-Feb-19RedValue 1
21-Mar-1931-Mar-19RedValue 2
31-Jan-1931-Mar-19BlueValue 3Value 3
4
5
6blue1/5/2019
Sheet
 
Upvote 0
A "Regular" formula, Suppose you have a header in row 1

<table border="1" cellspacing="0" style="font-family:Calibri,Arial; font-size:11pt; background-color:#ffffff; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:80.79px;" /><col style="width:80.79px;" /><col style="width:76.04px;" /><col style="width:76.04px;" /><col style="width:76.04px;" /><col style="width:90.3px;" /><col style="width:82.69px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td><td >D</td><td >E</td><td >F</td><td >G</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td style="background-color:#92d050; font-weight:bold; text-align:center; ">Date1</td><td style="background-color:#92d050; font-weight:bold; text-align:center; ">Date1</td><td style="background-color:#92d050; font-weight:bold; text-align:center; ">Color</td><td style="background-color:#92d050; font-weight:bold; text-align:center; ">Value</td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td style="text-align:right; ">01/01/2019</td><td style="text-align:right; ">28/02/2019</td><td >green</td><td >Value 1</td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td style="text-align:right; ">01/03/2019</td><td style="text-align:right; ">31/03/2019</td><td >Red</td><td >Value 2</td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >4</td><td style="text-align:right; ">01/01/2019</td><td style="text-align:right; ">31/03/2019</td><td >Blue</td><td >Value 3</td><td > </td><td >Value 3</td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >5</td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >6</td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >7</td><td > </td><td > </td><td > </td><td > </td><td > </td><td >blue</td><td style="text-align:right; ">05/01/2019</td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b>Formeln der Tabelle</b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Zelle</td><td >Formel</td></tr><tr><td >F4</td><td >=IFERROR(INDEX(D2:D4,SUMPRODUCT((A2:A4<=G7)*(B2:B4>=G7)*(C2:C4=F7)*(ROW(D2:D4)))-1),"Does not exist")</td></tr></table></td></tr></table>
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

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