Dynamic Change the Xlookup Return Array

smalik

Board Regular
Joined
Oct 26, 2006
Messages
186
Office Version
  1. 365
Platform
  1. Windows
Is there a way I can dynamically change the Return Array based on a value in another cell in an Xlookup formula?

For example, I am trying pull the data in various columns from another tab using the "Lookup Code"(Column B) as my lookup value.
1707153750420.png


Row 1 is the column header from another tab. For example, the "Prior Account ID" is in Column C from the "List" (source) Tab
The Xlookup formula in cell C5 is: =XLOOKUP($B5,List!$B:$B,List!C:C)

Is there a way I can dynamically change the Return Array based on what is in row 1? i.e., XLOOKUP($B5,List!$B:$B,List!C:C) to change to XLOOKUP($B5,List!$B:$B,List!AH:AH) automatically for the subsequent columns.

I used to be able to change the column number in Vlookup dynamically but not sure how to do this in Xlookup?

Any help is greatly appreciated.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
How about
Excel Formula:
=INDEX(List!$A$2:$AH$1000,XMATCH($B5,List!$B$2:$B$1000),XMATCH(C$4,List!$A$1:$AH$1))
 
Upvote 0
Solution
Awesome.... This works. I did not know the "xmatch" function. Learn something new everyday
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,141
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