How to make vlookup criteria use column header

chimneytop

New Member
Joined
Aug 13, 2015
Messages
7
I have two sheets. Sheet1 has a table of data that I will need to lookup, and I will be pasting data from another workbook into Sheet2 that has somewhat consistent column headers but in different orders. I want to put a formula in Sheet2!A:A that finds a specific column in the pasted data and then uses it lookup a value in Sheet1. I've made three examples of Sheet2 below

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]Check[/TD]
[TD="align: center"]Weight[/TD]
[TD="align: center"]Color[/TD]
[TD="align: center"]Material[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]=vlookup(OR("Material","Materials","Mat.","Mats")2,Sheet1!A3:C52,3,false)[/TD]
[TD="align: center"]5[/TD]
[TD="align: center"]Blue[/TD]
[TD="align: center"]Wood[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]=vlookup(OR("Material","Materials","Mat.","Mats")3,Sheet1!A3:C52,3,false)[/TD]
[TD="align: center"]6[/TD]
[TD="align: center"]Red[/TD]
[TD="align: center"]Rubber[/TD]
[/TR]
</tbody>[/TABLE]

Goal for A2 is to return same result as =vlookup(D2,Sheet1!A3:C52,3,false)

-----

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]Check[/TD]
[TD="align: center"]Weight[/TD]
[TD="align: center"]Color[/TD]
[TD="align: center"]Mats[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]=vlookup(OR("Material","Materials","Mat.","Mats")2,Sheet1!A3:C52,3,false)[/TD]
[TD="align: center"]5[/TD]
[TD="align: center"]Blue[/TD]
[TD="align: center"]Wood[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]=vlookup(OR("Material","Materials","Mat.","Mats")3,Sheet1!A3:C52,3,false)[/TD]
[TD="align: center"]6[/TD]
[TD="align: center"]Red[/TD]
[TD="align: center"]Rubber[/TD]
[/TR]
</tbody>[/TABLE]



Goal for A2 is to return same result as =vlookup(D2,Sheet1!A3:C52,3,false)

-----

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]Check[/TD]
[TD="align: center"]Color[/TD]
[TD="align: center"]Mat.[/TD]
[TD="align: center"]Weight[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]=vlookup(OR("Material","Materials","Mat.","Mats")2,Sheet1!A3:C52,3,false)[/TD]
[TD="align: center"]Blue[/TD]
[TD="align: center"]Wood[/TD]
[TD="align: center"]5[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]=vlookup(OR("Material","Materials","Mat.","Mats")3,Sheet1!A3:C52,3,false)[/TD]
[TD="align: center"]Red[/TD]
[TD="align: center"]Rubber[/TD]
[TD="align: center"]6[/TD]
[/TR]
</tbody>[/TABLE]


Goal for A2 is to return same result as =vlookup(C2,Sheet1!A3:C52,3,false)
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Code:
=VLOOKUP(INDIRECT(SUBSTITUTE(ADDRESS(1,MATCH("Mat*",$1:$1,0),4),"1","")&ROW(A2)),Sheet1!$A$3:$C$52,3,FALSE)
This will work as long as the column label starts with Mat. Also it will take only the first instance of Mat, meaning that if you have Mat. in column C and Materials in column D it will use column C in the vlookup. Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,239
Members
452,621
Latest member
Laura_PinksBTHFT

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