xlookup with index and match

Peter Davison

Active Member
Joined
Jun 4, 2020
Messages
444
Office Version
  1. 365
Platform
  1. Windows
I can't work out how I can use xlookup for a variable look up range based on a cell criteria?

I have a workbook 1 and sheet 1
I have a column (G) with a variable header in row 11 based on a drop down list selection
I'm trying to return a value from Workbook 2 Sheet 1 Range A35 to O1029 (with headings in row 34) which could be in columns F, I, L or O depending on the list selection above
So I am looking up a value in workbook 1 and sheet 1 Cell G12 and return in workbook 1 and sheet 1 Cell A12 what is in column A in Workbook 2 Sheet 1
So I can't see how I can use xlookup when my lookup column could be F, I, L or O.

If you have any thoughts it would be greatly appreciated.

Regards
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
I'm not sure if this worked below I used the quick wrap
I can't add the XL2BB because last time i did that it affected some workbooks I had.

Workbook 1
Excel Formula:

Workbook 2
Excel Formula:
 
Upvote 0
Just a heads up, I don't believe xlookup can access a "closed" workbook, so if you are expecting to have workbook 2 closed you might want to stay with index / match.
 
Upvote 0
@Peter Davison
Then please provide small data sample
If you want any look up function with criteria you have to add IF statement within.

This is the Table I learned it from (I'm not author of this data PMSOCHO is) he is Polish Excel trainer.

ex-285 - WYSZUKAJ.PIONOWO - kilka kryteriów - tablicowa z JEŻELI.xlsx
BCDE
1RegionStorageProductcode
2EastM3Lion272x
3
4RegionStorageProductcode
5WestM2Twix769x
6EastM2Mars409x
7WestM3Lion367x
8WestM1Twix901x
9WestM2Mars901x
10EastM1Lion237x
11WestM3Twix827x
12WestM3Mars649x
13EastM3Lion272x
14WestM1Lion447x
15EastM2Twix347x
16EastM2Lion340x
17WestM2Lion584x
18EastM1Mars225x
19EastM3Mars487x
20EastM1Twix128x
21EastM3Twix179x
22WestM1Mars474x
ex-285 zrobione
Cell Formulas
RangeFormula
E2E2=VLOOKUP(B2,IF((C5:C22=C2)*(D5:D22=D2),B5:E22,""),4,0)
Press CTRL+SHIFT+ENTER to enter array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E5:E22Expression=AND(D5=$D$2;C5=$C$2;B5=$B$2)textNO
Cells with Data Validation
CellAllowCriteria
B2ListEast;West
C2ListM1;M2;M3
D2ListMars;Lion;Twix


if you don't know which column number to use, that's fine, just in the col_index in VLOOKUP use Match function.
with XLOOKUP is bit more complicated.

If you might return multiple results then lookups are NOT the solution since they do not find duplicates (just the first found result)
in this case u must use = FILTER() function
 
Upvote 0
See if this works for you.

You will need to change the Workbook & Sheetname of the Workbook2 reference.
(My preference would be use a table in workbook2 rather than hardcode row 1029)


20210622 Xlookup 2nd Workbook.xlsx
ABCDEFG
1
2
3
4
5
6
7
8
9
10
11ReturnValueVariableHeader
12Return this valueItemToFind
13
14
Notes
Cell Formulas
RangeFormula
A12A12=XLOOKUP($G12,INDEX('[WorkBook2 Lookup Data.xlsx]Sheet1'!$A$34:$O$1029,0,MATCH($G$11,'[WorkBook2 Lookup Data.xlsx]Sheet1'!$A$34:$O$34,0)),'[WorkBook2 Lookup Data.xlsx]Sheet1'!$A$34:$A$1029,"Not Found",0)
 
Upvote 0
Solution

Forum statistics

Threads
1,215,580
Messages
6,125,654
Members
449,245
Latest member
PatrickL

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