Lookup values from a sheet where reference value and lookup value keeps changing column positions

eta004

New Member
Joined
Jun 26, 2016
Messages
15
Dear Experts,

My requirement is to lookup data corresponding to " Name" in Sheet 1 where every header is fixed in position, from Sheet2 where the reference value ("Name") as well as lookup values("rem") keeps changing postions(columns)..Due to this when using Vlookup which uses Row column reference will give me wrong results.

I tried INDEX MATCH function also but in that also I couldnt fix the row number for reference value ....Anyone kindly help as I am in bit of confusion ...and Im novice in VBA and macros.


=INDEX(Sheet2!$A$1:$D$9,MATCH(Sheet1!$A2,Sheet2!$B:$B,0),MATCH("rem",Sheet2!$1:$1,0))

In the above formaula I need help in the first MATCH function on how I can autodetect the " Sheet2!$B:$B" which keeps on changing in trends and detect the column in sheet2 which the corresponding header name "Name" .

I will simplify the scenario as below:

Sheet1:
A B C
NameAgeRemarks
daff1
aaa3
fgh2
a33
ggg77
d4
fff88
fffdfs90

<tbody>
</tbody>


Sheet 2:

A B C D
sl noNameagerem
1daff12cow
2aaa4dog
3fgh88sheep
4a6goat
5ggg9monkey
6d7bull
7fff88fox
8fffdfs5lion

<tbody>
</tbody>

Any methods are welcome....Pls help me out of this ..........
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
I have manged to put it this way

Dim ref As Integer









Sheets("Sheet2").Select
Range("F3").FormulaR1C1 = "=MATCH(""Name"",Sheet2!R1,0)"



ref = ActiveSheet.Cells(3, 6).Value


Sheets("Sheet1").Select
Range("E3").Select
ActiveCell.FormulaR1C1 = _
"=INDEX(Sheet2!R1C1:R9C4,MATCH(Sheet1!RC1,Sheet2!C" & ref & ",0),MATCH(""rem"",Sheet2!R1,0))"




End Sub



In this I need to avoid the "ref" value to be taken from a cell and need to directly apply to the formula.."=MATCH(""Name"",Sheet2!R1,0)"
Any ideas for that?

like ref="=MATCH(""Name"",Sheet2!R1,0)"
 
Upvote 0

Forum statistics

Threads
1,215,259
Messages
6,123,922
Members
449,135
Latest member
NickWBA

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