VLOOKUP Multiple Criteria Advanced

Mindtriks

New Member
Joined
Apr 11, 2016
Messages
14
Hey Guys - New to this forum, but I am having a lot of difficulty figuring out the code I want for a specific assignment.

I am working on a spreadsheet with two tabs. On tab one I have a list of doctor visits by patient with columns showing the ID number of the physician and the date the checkup occurred. On the second tab I have a list of contracted rates for each physican, but the rates vary depending on time frame (we usually contract for 6 months, 1 year, etc).

I want to match the ID number from tab 1 then go to tab 2 and find the associated physican, then go back to tab one find the start state of the doctor visit and then go back to tab 2 and then perform a vlookup for values on tab 2 (Columns D-F) based on when this individual saw the doctor (see which time frame the visit falls under and then perform the vlookup function on the appropriate row)


First table is Sheet 1 (Top Table), Second Table is Sheet 2 (Bottom Table)

ID Number
12450079
12450079
12450079
12450788
12450788
12450788
12450788
12450788
12450788
12450788
12450788
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450237
12450046
12450046
12450011
12450046
12450046
12450046
12450046
12450046
12450046
12450046
12450046
12450046
12450046
12450046
12450119
12450119
12450119
12450119
12450119
12450119
12450119
12450119
12450119
12450119
12450119
12450119
12450119
12450119
12450119
12450119
12450119
12450119
12450119
12450119
12450119
12450119

<colgroup><col></colgroup><tbody>
</tbody>
Start Date
6/1/2015
5/1/2015
5/30/2015
1/11/2015
4/22/2015
5/31/2015
1/17/2015
1/24/2015
2/11/2015
5/16/2015
3/29/2015
6/6/2015
1/29/2015
3/10/2015
3/17/2015
3/31/2015
4/15/2015
1/27/2015
3/3/2015
3/23/2015
4/4/2015
2/24/2015
4/3/2015
4/19/2015
5/9/2015
5/16/2015
2/19/2015
4/4/2015
5/21/2015
1/29/2015
4/4/2015
4/23/2015
3/3/2015
4/14/2015
4/15/2015
4/16/2015
1/28/2015
6/8/2015
2/9/2015
1/29/2015
1/21/2015
5/14/2015
5/25/2015
3/6/2015
3/26/2015
5/6/2015
5/15/2015
1/28/2015
5/20/2015
3/4/2015
4/15/2015
2/25/2015
5/31/2015
4/29/2015
4/23/2015
6/10/2015
3/28/2015
5/7/2015
6/17/2015
6/19/2015
6/7/2015
2/9/2015
4/19/2015
3/23/2015
5/30/2015
2/9/2015
3/22/2015
4/2/2015
6/5/2015
5/22/2015
1/22/2015
5/14/2015
2/18/2015
5/18/2015
2/2/2015
6/17/2015
5/16/2015
5/4/2015
5/27/2015
6/8/2015
5/3/2015
5/24/2015
6/8/2015
5/5/2015
5/5/2015
5/27/2015
5/19/2015
5/14/2015
5/25/2015
5/31/2015
6/5/2015
4/25/2015
5/22/2015
5/30/2015
5/14/2015
4/4/2015
5/10/2015
6/19/2015

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

<tbody>
</tbody>


ID NumberContract Start DateContract End DateCFDNEDSC
1245135910/3/20151/2/2012119
124513021/3/20124/2/2012105
124513201/3/20124/2/2012118
124513301/3/20124/2/2012100
124513321/3/20124/2/2012005
124513391/3/20124/2/2012000
124513411/3/20124/2/2012013
124513441/3/20124/2/20120111
124513561/3/20124/2/2012110
124513611/3/20124/2/2012003
124513701/3/20124/2/2012112
124513741/3/20124/2/2012012
124502964/22/20125/2/2012107
124505584/22/20125/2/2012103
124505653/20/20125/15/20121110
124501194/3/20125/16/2012109
124502094/3/20125/16/2012112
124500855/16/20125/26/2012109
124505973/20/20125/31/2012104
124500761/11/20126/1/2012117
124500294/22/20126/2/2012012
124502034/22/20126/2/2012113
124500183/10/20126/6/2012019
124507542/8/20126/12/2012103
124505373/9/20126/15/20120111
124502994/22/20126/16/2012116
124501474/22/20127/2/2012010
126700565/23/20127/2/2012014
124501526/17/20127/10/2012012
124501527/11/20127/16/2012018
124505964/22/20127/16/2012008
124504844/22/20128/2/2012006
124500236/2/20128/7/2012117
124500345/11/20128/7/2012116
124500405/31/20128/7/2012108
124500424/18/20128/7/2012118
124500514/4/20128/7/2012005
124500523/31/20128/7/2012012
124500766/2/20128/7/2012008
124500874/22/20128/7/20120011
124501246/2/20128/7/2012006
124501767/11/20128/7/2012004
124501964/29/20128/7/2012019
124502354/21/20128/7/2012106
124503476/24/20128/7/2012114
124503886/16/20128/7/2012111
124503893/23/20128/7/2012000
124504035/27/20128/7/2012114
124504113/18/20128/7/2012012
124504603/22/20128/7/2012002
124504885/11/20128/7/2012104
124504974/4/20128/7/20120011
124505083/30/20128/7/2012001
124505634/18/20128/7/2012102
124506474/20/20128/7/2012017
124506694/19/20128/7/2012111
124506705/9/20128/7/2012004
124506722/9/20128/7/2012007
124506976/22/20128/7/2012007
124507096/3/20128/7/2012108
124507234/5/20128/7/2012011
124507424/25/20128/7/2012004
124508326/2/20128/7/2012119
124508394/22/20128/7/2012019
124508674/27/20128/7/2012015
124508844/19/20128/7/2012105
126700234/12/20128/7/2012107
124500024/21/20128/9/20121011
124507741/5/20128/10/2012008
124501195/17/20128/16/20120011
124502095/17/20128/16/2012016
124502727/11/20128/16/20120111
124504474/22/20128/16/2012009
124506777/11/20128/16/2012003
124506884/22/20128/16/2012008
124501048/8/20128/21/2012110
124500338/8/20128/22/20121011
124500998/8/20128/23/2012011
124502718/8/20128/25/20120010
124500108/8/20128/26/2012010
124500518/8/20128/28/2012118
124502118/8/20128/28/2012103
124502808/8/20128/29/2012010
124507238/8/20128/30/2012004
124500978/8/20128/31/2012007
124501628/8/20128/31/20120110
124506434/3/20129/2/2012105
124507024/22/20129/2/20121110
124500648/8/20129/5/2012116
124502008/8/20129/5/20120111
124506048/8/20129/5/2012105
124506158/8/20129/5/2012110
124507975/25/20129/5/2012106
124508458/8/20129/5/2012103
124508908/8/20129/5/2012016
124508448/8/20129/6/2012106
124508478/8/20129/8/2012105
124506448/8/20129/11/20120111

<colgroup><col><col><col><col><col span="2"></colgroup><tbody>
</tbody>

<tbody>
</tbody>





 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Using Sumproduct will render the results you seek.
This formula uses Sheet1 (Physician Contract Data) and Sheet2 (Patient Data) as Sheet Names replace accordingly also the range is for up to 5000 rows of data that can be adjusted as well.
This formula will return the results for Column D You can change the D Range to E, F,or G for which ever column you would like to pull from.
=SUMPRODUCT(--((Sheet1!$A$1:$A$5000=Sheet2!A2)),--((Sheet1!$B$1:$B$5000< Sheet2!B2)),--((Sheet1!$C$1:$C$5000> Sheet2!B2)),(Sheet1!$D$1:$D$5000))
 
Last edited:
Upvote 0
Hi Latchmaker - This formula doens't seem to be working. I've tried to clarify what I am looking for below via an example:

I am looking to bring the values from columns D-F on sheet 2 to columns 3-5 on sheet 1 and make sure the values brought over are the ones that correspond with the appropriate contract date. For example, I would look at the ID Number (12450079) on Sheet 1, Column A, Row 2. I would then go to Sheet 2 and find all the rows that had that matching ID Number. Then I would go back to Sheet 1 looking at Column B, Row 2 to see the Contract start date. Then from the filtered results on Sheet 2 I would want to grab the values in Columns D-F for which row the contract start dates falls within (See Columns B and C). Please let me know if that helps.
 
Upvote 0
Would it be an acceptable solution to include re-sorting the second table, first on ID number, then on Contract Start Date ?
 
Upvote 0
I'm not quite sure what you are saying, could you elaborate? I understand the sorting, but I'm not sure how that will help me here. In the actual SS which I had to alter there are around 700 rows on one sheet and 5000 on another. I need to certain values to be pulled into columns (the values at the time of the negotiated contract rate, sheet 2) and then have them inserted into sheet 1. I then perform a list of functions on the given values.
 
Upvote 0
Hello Mindtriks,

I may be a little confused on what you're trying to achieve but it may seem that an INDEX MATCH array formula would work.
The index match works similar to the vlookup formula, but has a lot more versatility. Please change the sheet name and column references according to your workbook.

=INDEX(Sheet2!D:D,MATCH(1,(Sheet1!A2=Sheet2!A:A)*(Sheet1!B2=Sheet2!B:B),0))

Remember, array formulas have to be entered by using "CTRL+SHIFT+ENTER" instead of just enter when typing in the formula. (two curly braces should appear around the formula when looking at the formula bar)

"Sheet2!D:D" would be the result that would populate,"Sheet1!A2" is the ID number on the first sheet that you're looking up on "Sheet2!A:A" and "Sheet1!B2" is the date that you would be looking on on "Sheet2!B:B".
 
Upvote 0
Hi D_zee315,

The formula seems close to what I need, but the values on Sheet 1 in column B are an exact date. On Sheet 2 there is a date range starting in column B and ending in column C. For example, the date could be 1/1/15 on Sheet 1, then on Sheet 2 I need to look at the start date (column B) and end date (column C) and then need to MATCH the Fixed Date with the appropriate date range from columns B and C and then pull the values in the other columns that correspond with that date. Does that make any more sense?
 
Upvote 0
Hello Mindtriks,

I see, so if you want the data pull based on if the start date from sheet 1 falls between the contract start date and contract end date on sheet 2, then this should work:

=INDEX(Sheet2!D:D,MATCH(1,(Sheet1!A2=Sheet2!A:A)*(IF(Sheet1!B2>=Sheet2!B:B,IF(Sheet1!B2<=Sheet2!C:C,1))),0))

Same deal as before, enter it using CTRL+SHIFT+ENTER.

Let me know if this works out for you or if I missed something.
 
Upvote 0
This was perfect and worked great. Thanks again for all the help. Also, why do you use the Asterisk (before the IF statement)?
 
Upvote 0
The Asterisks are used as a multiplication or an "AND" (however you want to look at it). I used it with the Match formula for the multiple criteria factor you were looking for.

Example, this is what the single criteria for the ID number would be so you can see the difference:

=INDEX(Sheet2!D:D,MATCH(Sheet1!A2,Sheet2!A:A,0))

This formula would NOT need to use CTRL+SHIFT+ENTER, but it will only return the value from the first time the ID number comes up on Sheet2!A:A.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,089
Messages
6,128,760
Members
449,466
Latest member
Peter Juhnke

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