Vlookup - editable index

MarkCBB

Active Member
Joined
Apr 12, 2010
Messages
497
Hi there,

This question is more out of curiosity than necessity. Does anyone know of a Function that has been made that adds an argument to the vlookup Function that allows for the index column to be choosen as the result column is choosen. i.e.
Code:
=vlookup(A1,2,C:F,4,0)

the 2 is the index column = Column "D" and the result column is "F".
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
VLOOKUP looks in the leftmost column of lookup range. You could use INDEX or OFFSET to construct that argument. What are you trying to do exactly?
 
Upvote 0
Hi Andrew,

Example: I have a datatable ("Table1") that has a few index columns in it. i.e. Product, sales code. Depending on the infoamtion i have to find the relevete corisponding infomation, I would use either one, the one formula would use Table1 as the table the ither would use B:G as the table.

More interested as to if there is a custom function that has been made that can do this.

How would you approach this?
 
Upvote 0
If J1 contains the starting column number you can construct a reference that starts at that column with:

OFFSET(Table1,0,J1-1,,COLUMNS(Table1)-J1+1)
 
Upvote 0
Curiosity has now increase, It seems that this should be a function in Excel, would really be helpful.

I used your Formula above and ended up with this:

Named: "TableRange"
=OFFSET(Sheet1!$A$1,0,ColumnName,COUNTA(Sheet1!$A:$A),COUNTA(Sheet1!$1:$1)-ColumnName)

"Column Range"
=MATCH(Sheet2!$A$1,Sheet1!$A$1:$G$1,0)-1

Sheet2 "A1" would be the name of the Column. Sheet2 "B1" would be the lookup_Value. Sheet2 "C1" =VLOOKUP(B1,TableRange,2,0)

Just curious to how much work it would take to create this as a function. So that Sheet2 "A1" is not needed to create the column Index Number, but would be an Argument in the Vlookup.

Just seems that this would be pretty cool. But the above works perfectly as well.

Thank you for your assistance.

Regards,
Mark Blackburn
 
Upvote 0
I was thinking you could use OFFSET inside the VLOOKUP formula to return the lookup range, not to define a name.
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

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