How to vlookup with 2 criteria's (a direct matching criteria and an approximately matching criteria)?

karthick019

New Member
Joined
Jul 15, 2011
Messages
10
Dear all,

My question is based on the sample table below,

PartDatePrice
A01/01/2010100
A01/05/2010200
A01/01/2011300
A01/03/2012400
A01/04/2013100
B01/04/2010600
B01/06/2011700
B01/08/2012800
B01/09/2012900
B01/04/2013100

<colgroup><col><col><col></colgroup><tbody>
</tbody>


I need a formula with 2 criteria's where part number is matched directly and i have a date and need to find the closest minimum range and update the price for the same.

Eg,

When I enter Part number as "A" and Date as "05/09/2012". the price should be matched as below,
(Part=A) & (Date = closest minimum date) ie. "01/03/2012" in this case.

PartDatePrice
A05/09/2012400

<colgroup><col><col><col></colgroup><tbody>
</tbody>

I tried searching for this but I am left with no answers. Help me out excel experts. :(:(
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
With your data in columns A:C, the part to search for in E1 and the date to search for in F1;

=INDEX(C:C,MATCH(F1,IF(A:A=E1,B:B),1))

array entered with CTRL+SHIFT+ENTER

Does this work?
 
Upvote 0
Welcome to the MrExcel board!

If the dates for each part number are in ascending order, as yours appear to be, then Daveydoodles formula I think should do the job, though I would definitely not use whole column references. No use checking 1,000,000+ rows if you are only using 100 or so for example.

If you are using Excel 2010 or later you can use the standard formula in F3 below.
Otherwise, the formula in F4 which will work in all versions and would still work if the dates are not in ascending order. It is also an array formula so should be entered without the {} but confirmed with Ctrl+Shift+Enter, not just Enter. If confirmed correctly, Excel will insert the {}.

Excel Workbook
ABCDEF
1PartDatePricePartA
2A1/01/10100Date5/09/12
3A1/05/10200Price400
4A1/01/11300400
5A1/03/12400
6A1/04/13100
7B1/04/10600
8B1/06/11700
9B1/08/12800
10B1/09/12900
11B1/04/13100
12
Lookup Value
 
Upvote 0
With your data in columns A:C, the part to search for in E1 and the date to search for in F1;

=INDEX(C:C,MATCH(F1,IF(A:A=E1,B:B),1))

array entered with CTRL+SHIFT+ENTER

Does this work?

Wow Daveydoodles. That worked like a charm.
I was spending hours to figure this out... Thanks a lottt mate.

This s a very good learning for me. :biggrin:
 
Upvote 0
Welcome to the MrExcel board!

If the dates for each part number are in ascending order, as yours appear to be, then Daveydoodles formula I think should do the job, though I would definitely not use whole column references. No use checking 1,000,000+ rows if you are only using 100 or so for example.

If you are using Excel 2010 or later you can use the standard formula in F3 below.
Otherwise, the formula in F4 which will work in all versions and would still work if the dates are not in ascending order. It is also an array formula so should be entered without the {} but confirmed with Ctrl+Shift+Enter, not just Enter. If confirmed correctly, Excel will insert the {}.

Lookup Value

ABCDEF
1PartDatePrice PartA
2A1/01/10100 Date5/09/12
3A1/05/10200 Price400
4A1/01/11300 400
5A1/03/12400
6A1/04/13100
7B1/04/10600
8B1/06/11700
9B1/08/12800
10B1/09/12900
11B1/04/13100
12

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:56px;"><col style="width:56px;"><col style="width:81px;"><col style="width:56px;"><col style="width:56px;"><col style="width:85px;"></colgroup><tbody>
</tbody>

Spreadsheet Formulas
CellFormula
F3=AGGREGATE(14,6,(A2:A11=F1)*(B2:B11<=F2)*C2:C11,1)
F4{=MAX(IF(A2:A11=F1,IF(B2:B11<=F2,C2:C11)))}

<tbody>
</tbody>
Formula Array:
Produce enclosing
{ } by entering
formula with CTRL+SHIFT+ENTER!

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4


Peter & Daveydoodles. You both are genius.

Thanks a lot for your very quick reply. I'll try out your function as well... Thanks again...!!
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,535
Members
449,037
Latest member
tmmotairi

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