vlookup choice from 2 left hand columns

mistersteve

Board Regular
Joined
Aug 18, 2014
Messages
109
Office Version
  1. 365
Hello all,
Please forgive me if I don't explain properly
Using vlookup from another spreadsheet
I select from the table array as below and select column C as result

However, there are in some instances there is a part number in column B
Therefore, can it be possible to ignore Column A as first left column and choose Column B whenever there is a part number present

A B C
Group Part Number Discount
1 P302 15
2 P311 40
3 P179 25
4 P179 12345 57.62

Hoping this can be answered and thankyou in advance
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
64,052
Office Version
  1. 365
Platform
  1. Windows
How about
Excel Formula:
=XLOOKUP(A2,Sheet1!$B$2:$B$20,Sheet1!$C$2:$C$20,XLOOKUP(A2, Sheet1!$A$2:$A$20,Sheet1!$C$2:$C$20,"",0),0)
 

mistersteve

Board Regular
Joined
Aug 18, 2014
Messages
109
Office Version
  1. 365
How about
Excel Formula:
=XLOOKUP(A2,Sheet1!$B$2:$B$20,Sheet1!$C$2:$C$20,XLOOKUP(A2, Sheet1!$A$2:$A$20,Sheet1!$C$2:$C$20,"",0),0)
Thank you Fluff, unfortunately i don't have XLOOKUP on office 2016,
is there another way i could use
 

alansidman

Well-known Member
Joined
Feb 26, 2007
Messages
6,578
Office Version
  1. 365
Platform
  1. Windows
You could use this:
=vlookup(X,choose({1,2},B:B,A:A),2,0)

where X is your criteria, your data is in columns A and B and the match is in Column B and the needed data is in column A.​
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
64,052
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

unfortunately i don't have XLOOKUP on office 2016,
Then why are you showing 365 in your profile, if your using 2016?
 

Alex Blakenburg

Well-known Member
Joined
Feb 23, 2021
Messages
2,062
Office Version
  1. 365
Platform
  1. Windows
This should give the same result as Fluff's Xlookup.
It assumes the value to lookup is in A2 that is on the same sheet as the formula.

Excel Formula:
=IFERROR(VLOOKUP($A2,Sheet1!$B$2:$C$20,2,FALSE),
       IFERROR(VLOOKUP($A2,Sheet1!$A$2:$C$20,3,FALSE),
          ""))

If anyone else want to try here is the data in XL2BB

20210730 Vlookup nested.xlsx
ABCD
1GroupPart NumberDiscount
2P30215
3P31140
4P17925
5P1791234557.62
6
Sheet1
 

mistersteve

Board Regular
Joined
Aug 18, 2014
Messages
109
Office Version
  1. 365

ADVERTISEMENT

Hi Alex
is it me? because I keep getting the answer of 25 and not 57.62
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
64,052
Office Version
  1. 365
Platform
  1. Windows
In that case I would suggest you change your profile to show 2016 & when a 365 solution is ok say so in your post.

Alex's formula works for me.
 

Forum statistics

Threads
1,144,514
Messages
5,724,805
Members
422,579
Latest member
parsnipsnatcher

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
Top