Need to VLOOKUP within Range

ranjith2523

Board Regular
Joined
Apr 29, 2014
Messages
137
Office Version
  1. 365
Hi Friends,

I need to apply a vlookup or other alternate formula to lookup a price within a range and get the output based on the match.

In the below table, I have the price in column A and the value in column B. We have price range data in the D to F column and in the G column I need to put a lookup formula.

For example, if you look into cell G4 it appears as "Used" (cell B2) since the price 2400 (cell A2) falls between range 2359 to 2465. If there is no match then we can leave the cells as blank.

I tried to apply vlookup formula using "Approximate Match" but it didn't work out for me :( .

Can someone please help me to sort it out.

PriceValueStartMidEndValue
2400Used2,1582,2072,255
3000Match2,2562,3072,358
3750Delete2,3592,4122,465Used
5000Retain2,4662,5222,577
2,9453,0123,078Match
3,0793,1493,218
4,7934,9015,009Retain
5,0105,1235,235



Regards,
Ranjith
 
So D, E, and F are the range? A is the price you're manually inputting? And B is the column that needs to change based upon the values in column A? Is that correct?
 
Upvote 0

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
So D, E, and F are the range? A is the price you're manually inputting? And B is the column that needs to change based upon the values in column A? Is that correct?

Really sorry, i think i need to explain better.

Yes D, E and F are the range.
Yes, A is the price which we manually input.
NO, B is also a manual input value.

Actually, everything is a manual input except column G. Let me try to explain better.

In below table, i have changed the headers for better understanding. We need to put a formula in Column G to see what prize for what Lottery Number Range.

Lottery NumberPrizeStartMidEndPrize
2400Headset2,1582,2072,255NO_PRIZE
3000TV2,2562,3072,358NO_PRIZE
5000Radio2,3592,4122,465Headset
2,4662,5222,577NO_PRIZE
2,9453,0123,078TV
3,0793,1493,218NO_PRIZE
4,7934,9015,009NO_PRIZE
5,0105,1235,235Radio
 
Upvote 0
Can someone please help me with this? I tried to write the formula but I failed :(

I have been doing this manually for the past couple of hours.

Regards,
Ranjith
 
Upvote 0
See if one of these works for you:

Book1
ABCDEFGH
1PriceValueStartMidEndValue XlookupValue Filter
22400Used215822072255  
33000Match225623072358  
43750Delete235924122465UsedUsed
55000Retain246625222577  
6294530123078MatchMatch
7307931493218  
8479349015009RetainRetain
9501051235235  
Data
Cell Formulas
RangeFormula
G2:G9G2=XLOOKUP(1,($A$2:$A$5>=D2)*($A$2:$A$5<=F2),$B$2:$B$5,"")
H2:H9H2=FILTER($B$2:$B$5,($A$2:$A$5>=D2)*($A$2:$A$5<=F2),"")
 
Upvote 0
Solution
See if one of these works for you:

Book1
ABCDEFGH
1PriceValueStartMidEndValue XlookupValue Filter
22400Used215822072255  
33000Match225623072358  
43750Delete235924122465UsedUsed
55000Retain246625222577  
6294530123078MatchMatch
7307931493218  
8479349015009RetainRetain
9501051235235  
Data
Cell Formulas
RangeFormula
G2:G9G2=XLOOKUP(1,($A$2:$A$5>=D2)*($A$2:$A$5<=F2),$B$2:$B$5,"")
H2:H9H2=FILTER($B$2:$B$5,($A$2:$A$5>=D2)*($A$2:$A$5<=F2),"")
Oh My God !!! You are just awesome :)

The below formula works as expected and it meets my requirements :) Thank you so much, Mr. Alex.

Just to gain my knowledge, could you please break the formulas into separate pieces and explain to me how it work? Your explanation will also help other people to gain some knowledge.

=XLOOKUP(1,($A$2:$A$5>=D2)*($A$2:$A$5<=F2),$B$2:$B$5,"")
 
Upvote 0
The components I used in the Xlookup are:
=XLOOKUP(lookup_value, lookup_array, return_array, if_not_found)
The key part is the lookup_array. Here we put multiple conditions linked by multiplication "*".
Each condition returns an array of Trues and Falses.
The multiplication then does 2 things it converts True to 1 and False to 0 and then by the act of mutliplying performs an AND condition since only 1 * 1 (all are true) will return 1 anything else will return 0.
(your condition being that you want the value in column A to be between the value in D & F)

Since we now have an array of 1s and 0s the lookup_value needs to be 1.

You will find a very good complete more explanation here:
 
Upvote 0
The components I used in the Xlookup are:
=XLOOKUP(lookup_value, lookup_array, return_array, if_not_found)
The key part is the lookup_array. Here we put multiple conditions linked by multiplication "*".
Each condition returns an array of Trues and Falses.
The multiplication then does 2 things it converts True to 1 and False to 0 and then by the act of mutliplying performs an AND condition since only 1 * 1 (all are true) will return 1 anything else will return 0.
(your condition being that you want the value in column A to be between the value in D & F)

Since we now have an array of 1s and 0s the lookup_value needs to be 1.

You will find a very good complete more explanation here:
Perfect Mr.Alex.. Thank you so much for your help :)
 
Upvote 0
Perfect Mr.Alex.. Thank you so much for your help :)
The marked solution has been changed accordingly. In your future questions, please mark the post as the solution that actually answered your question, instead of your feedback message as it will help future readers. No further action is required for this thread.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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