How To Filter the Range in a VLOOKUP Function

jahinton

New Member
Joined
Mar 4, 2018
Messages
4
I need help to accomplish something with a VLOOKUP command. I have a feeling it involves using some kind of array but am just struggling trying to find a solution. Obviously I am NOT an Excel power user. So if you have an answer for me, please help me understand it with easy explanations.

I want to look up a value in a range based on a lookup value, but I need to filter other columns in the range I'm using before returning the value in the designated column. Let me show you an example of the data in the target range:

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]PAYMENT[/TD]
[TD]PBM[/TD]
[TD]Account[/TD]
[TD]Product[/TD]
[TD]Measure[/TD]
[TD]2/9/2017[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Commercial[/TD]
[TD]*Total[/TD]
[TD]*Total[/TD]
[TD]Advair[/TD]
[TD]NBRx Shr[/TD]
[TD]32.67%[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Commercial[/TD]
[TD]Aetna[/TD]
[TD]Coventry[/TD]
[TD]Advair[/TD]
[TD]NBRx Shr[/TD]
[TD]34.89%[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Commercial[/TD]
[TD]Aetna[/TD]
[TD]Aetna[/TD]
[TD]Symbicort[/TD]
[TD]NBRx Shr[/TD]
[TD]40.28%[/TD]
[/TR]
</tbody>[/TABLE]

So this is what I'm trying to do. I'm trying to use the value in A2 below as my lookup value. Then reference the range above and return ONLY the value in cell F2 (32.67%). So I want to match the lookup value "Commercial" with the PAYMENT column but filter the rest of the columns so that I'm only selecting the "Commercial" value that has a value of "*Total" in column B, "*Total" in column C, "Advair" in column D, and "NBRx Shr" in column E. What kind of combination of functions do I need to do that?

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]PAYMENT[/TD]
[TD]NBRx Share[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Commercial[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Thanks in advance to anyone who can help me!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Book1
ABCDEF
1PAYMENTPBMAccountProductMeasure02/09/2017
2Commercial*Total*TotalAdvairNBRx Shr32.67%
3CommercialAetnaCoventryAdvairNBRx Shr34.89%
4CommercialAetnaAetnaSymbicortNBRx Shr40.28%
Sheet1



Book1
AB
1PAYMENTNBRx Share
2Commercial32.67%
Sheet2
Cell Formulas
RangeFormula
B2{=INDEX(Sheet1!F:F,MIN(IF(Sheet1!A:A=$A2,IF(Sheet1!B:B="*Total",IF(Sheet1!C:C="*Total",IF(Sheet1!D:D="Advair",IF(Sheet1!E:E="NBRX Shr",ROW(Sheet1!A:A))))))))}
Press CTRL+SHIFT+ENTER to enter array formulas.


WBD
 
Upvote 0
Oh thank you for the fast response!! I so appreciate it. However it is not QUITE working right for me. If I change the "Advair" value to "Symbicort" it is still showing the value of 32.67% from the Advair row. What am I to do differently?
 
Upvote 0
Also... why does it return 32.67% if I just hit enter, but if I treat it as an array formula and use Ctrl-Shift+Enter, I get a result of 42775. I don't even know where that number is coming from.
 
Upvote 0
It has to be an array formula in order to work. 42775 is 9th February in numeric form; you'll probably get this if there's no match on the criteria. Here's my working example again:


Book1
ABCDEF
1PAYMENTPBMAccountProductMeasure09/02/2018
2Commercial*Total*TotalAdvairNBRx Shr32.67%
3CommercialAetnaCoventryAdvairNBRx Shr34.89%
4CommercialAetnaAetnaSymbicortNBRx Shr40.28%
5Commercial*Total*TotalSymbicortNBRx Shr37.29%
Sheet1



Book1
AB
1PAYMENTNBRx Share
2Commercial32.67%
3Commercial37.29%
Sheet2
Cell Formulas
RangeFormula
B2{=INDEX(Sheet1!F:F,MIN(IF(Sheet1!A:A=$A2,IF(Sheet1!B:B="*Total",IF(Sheet1!C:C="*Total",IF(Sheet1!D:D="Advair",IF(Sheet1!E:E="NBRX Shr",ROW(Sheet1!A:A))))))))}
B3{=INDEX(Sheet1!F:F,MIN(IF(Sheet1!A:A=$A3,IF(Sheet1!B:B="*Total",IF(Sheet1!C:C="*Total",IF(Sheet1!D:D="Symbicort",IF(Sheet1!E:E="NBRX Shr",ROW(Sheet1!A:A))))))))}
Press CTRL+SHIFT+ENTER to enter array formulas.


WBD
 
Upvote 0
I'm not getting the same results. As I paste the formula in the next cell down (B3 in Sheet 2), I get the number from the next cell down from Sheet 1 (F3 in Sheet 1). That is if I enter the formula without entering it an array formula. If I enter it as an array formula, I get that number - 42775. Could this have anything to do with the fact that I'm on a Mac? I looked up the keys for entering an array on Mac and it was Ctrl-Shift-Enter. So I'm doing that and it puts the curly brackets in but returns 42775. Maybe I need to enter this question on a new thread???
 
Upvote 0
Note that it's checking for the pattern:

Commercial, *Total, *Total, Symbicort, NBRx Shr

If it doesn't find it, you'll get the date from the top of the column.

WBD
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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