Lookup with 2 criterias

feni1388

Board Regular
Joined
Feb 19, 2018
Messages
61
Office Version
  1. 2021
Platform
  1. Windows
Hello...

As the image that I uploaded, I need to do a lookup with 2 criterias.
I'm combining if and vlookup together to get the result.
But the thing is that the rank sometimes changes to A4 or A6 and so on.
When the rank changes, I just need to paste a new table but then I also need to change the current formula that I'm using.
Is there any formula that won't need any adjustment even if the rank changes?
If possible, I don't want to use xlookup as there're still some old version of excel in some computers that can't use it.

Thank you.
 

Attachments

  • lookup with 2 criterias.PNG
    lookup with 2 criterias.PNG
    34.5 KB · Views: 19

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Would index/match work for you? Your Rank cells are merged so it's hard to say which cell contains the actual text. Adjust B3:I3 as needed.

Excel Formula:
=INDEX(B6:I0,MATCH(L5,A6:A9,0),MATCH(M3,B3:I3,0))
 
Upvote 0
Solution
@Cubist
That isn't a valid formula.

@feni1388
If you want to stick with VLOOKUP see if this works for you.

BTW, I suggest that you investigate XL2BB for providing sample data to make it easier for helpers by not having to manually type out sample data to test with.

24 03 27.xlsm
ABCDEFGHIJKLMN
1S5E5A5C5
2
3C5
4SellingCartonSellingCartonSellingCartonSellingCarton
5AB0270
6AB024861426289477091AB0591
7AB033355545297317461
8AB057716909373819146
9AB063195454774996282
Price
Cell Formulas
RangeFormula
M5:M6M5=VLOOKUP(L5,A$6:I$9,MATCH(M$3,A$1:I$1,0))
 
Upvote 0
@Peter_SSs Can you point out what's wrong?

EDIT I see the range is wrong for I0. Fat fingers. The 0 is next to the 9.

Book2
ABCDEFGHIJKLMN
1B5E5A5C5
2
3C5
4SellingCartonSellingCartonSellingCartonSellingCarton
5AB0270
6AB024861426289477091AB0591
7AB033355545297317461
8AB057716909373819146
9AB063195454774996282AB0270
10AB0591
Sheet2
Cell Formulas
RangeFormula
M5:M6M5=VLOOKUP(L5,A$6:I$9,MATCH(M$3,A$1:I$1,0))
M9:M10M9=INDEX($B$6:$I$9,MATCH(L9,$A$6:$A$9,0),MATCH($M$3,$B$1:$I$1,0))
 
Last edited:
Upvote 0
You're welcome. Glad we could help. Thanks for the follow-up. :)
 
Upvote 0
@Peter_SSs

As my list is actually longer, I tried a few more items, but the strange thing is that sometimes the result is off.
I don't know why. So I tried Cubist's solution and it's all OK.
 
Upvote 0
@Peter_SSs

As my list is actually longer, I tried a few more items, but the strange thing is that sometimes the result is off.
I don't know why. So I tried Cubist's solution and it's all OK.
As I see it the two formulas should return identical results.
I'd be interested to see some sample data where that happened so I could investigate. Could you provide that, preferably with XL2BB but failing that copy/paste directly into your post?
 
Upvote 0
Cost500500600800   
   
RankS5E5A5C5 
 A5 
   vlookupindex
ItemSelling priceCartonSelling priceCartonSelling priceCartonSelling priceCartonAB02
10,320​
435​
AB05
5,400​
92​
AB02
425​
10,200​
430​
10,320​
435​
10,440​
440​
10,560​
   
AB03
345​
8,280​
350​
8,400​
355​
8,520​
360​
8,640​
   
AB05
88​
5,280​
90​
5,400​
92​
5,520​
94​
5,640​
   
AB06
62​
7,440​
63​
7,560​
64​
7,680​
65​
7,800​
   
AB07
345​
8,280​
350​
8,400​
355​
8,520​
360​
8,640​
   
AB44
72​
8,640​
73​
8,760​
74​
8,880​
75​
9,000​
   
AS02
60​
3,600​
63​
3,780​
66​
3,960​
66​
3,960​
   
AS03
60​
3,600​
63​
3,780​
66​
3,960​
66​
3,960​
   
AS05
300​
7,200​
310​
7,440​
320​
7,680​
320​
7,680​
   

I don't have the original sample anymore so I paste the one that I have now.
Somehow I couldn't make it work with vlookup that you gave me.
 

Attachments

  • sample.PNG
    sample.PNG
    45.4 KB · Views: 3
Upvote 0
Thanks for providing the extra information, sample and image (though using XL2BB would have been better ;)). The issue is that you have altered one of the ranges incorrectly. The B shown here should be A as it was in my original formula. :)

1712047087663.png


With that correction, here are the two formulas again producing the same results. One is not really better than the other, just different ways of approaching the question.

24 03 27.xlsm
ABCDEFGHIJKLM
1Cost500500600800
2
3RankS5E5A5C5
4A5
5vlookupindex
6ItemSelling priceCartonSelling priceCartonSelling priceCartonSelling priceCartonAB02435435
7AB059292
8AB0242510,20043010,32043510,44044010,560
9AB033458,2803508,4003558,5203608,640
10AB05885,280905,400925,520945,640
11AB06627,440637,560647,680657,800
12AB073458,2803508,4003558,5203608,640
13AB44728,640738,760748,880759,000
14AS02603,600633,780663,960663,960
15AS03603,600633,780663,960663,960
16AS053007,2003107,4403207,6803207,680
Price (2)
Cell Formulas
RangeFormula
L6:L7L6=VLOOKUP(K6,A$8:I$16,MATCH(L$4,A$3:I$3,0))
M6:M7M6=INDEX($B$8:$I$16,MATCH(K6,$A$8:$A$16,0),MATCH($L$4,$B$3:$I$3,0))
 
Upvote 0

Forum statistics

Threads
1,215,080
Messages
6,123,013
Members
449,093
Latest member
ikke

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