How do I use Index & Match to reference a separate sheet?

kminh

New Member
Joined
Nov 10, 2019
Messages
1
I have the following test code that is working where column H is equal to what's in column B versus column D


Range("H2:H17") = "=INDEX(D2:D17,MATCH(B2:B17,B2:B17,0))"




Column B Column D Column H
A Test1 Test1
B Test2 Test2
C Test 3 Test3
D Test 4 Test4
E Test 5 Test5
F Test 6 Test6
G Test 7 Test7
H Test 8 Test8
I Test 9 Test9
J Test 10 Test10




Question:




How do I use the same code to reference a seperate table called "temp" to do the same thing. The idea is for each time the code looks for 'target' it does
an index and match checking column B to equal what's in column D so if the value A is passed then it would become Test1? I tried the following code, but get error "Sub or Function not defined"
when it comes to 'Match' and the code stops.




TargetPortF = Application.WorksheetFunction.Index(Sheets("Temp").Range("D2:D17"), Match(Sheets("Temp").Range("B2:B17"), Sheets("Temp").Range("B2:B17"), 0))




Any help is appreciated!
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Try qualifying match:

VBA Code:
b = WorksheetFunction.Index(Sheets("SI").[B2:B31], _
    WorksheetFunction.Match(a, Sheets("SI").[A2:A31], 0))
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,130
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