sllaksvb
09-08-2017, 09:07 AM
Hi all,
I am trying to use index match function to index column A of Sheet 2, and match each value of column E in Sheet 1 with the values of column C in Sheet 2. And if the codes match, to return the value in column A of sheet 2 into the corresponding row in sheet 1. I can't seem to get the syntax right for the index match function, would appreciate if someone could help!
Range("D3").Select
Range(Selection, Selection.End(xlDown)).Select
RowNum = Selection.Rows.Count + 2
For i = 3 To RowNum
Sheets("Sheet1").Cells(i,3).Value = Application.WorksheetFunction.Index(Sheets("Sheet2").Range ("A:A"), Application.WorksheetFunction.Match(Sheets("Sheet1").Cells(i, 5), Sheets("Sheet2").Range("C:C"), 0)
Next i
I am trying to use index match function to index column A of Sheet 2, and match each value of column E in Sheet 1 with the values of column C in Sheet 2. And if the codes match, to return the value in column A of sheet 2 into the corresponding row in sheet 1. I can't seem to get the syntax right for the index match function, would appreciate if someone could help!
Range("D3").Select
Range(Selection, Selection.End(xlDown)).Select
RowNum = Selection.Rows.Count + 2
For i = 3 To RowNum
Sheets("Sheet1").Cells(i,3).Value = Application.WorksheetFunction.Index(Sheets("Sheet2").Range ("A:A"), Application.WorksheetFunction.Match(Sheets("Sheet1").Cells(i, 5), Sheets("Sheet2").Range("C:C"), 0)
Next i