raabouza
06-18-2019, 07:48 PM
Greetings,
I am trying to determine why the code "code/file attached within" is not returning the values that I need, no luck so far.
My goal is to take the value in A from sheet 1, match it in B from sheet 2 to determine the row number then copy E & F values from the same line "sheet 2" and return it to the corresponding row/column in sheet 1.
I am kindly seeking your assistance to point me in the right direction.
Thank you.
RA
Sub HR_Lookup()
' Look for HR# and copy a specific field
Dim iRow As Long
Dim wb1 As Workbook
Dim c As Range
Dim rngSearch As Range
Set wb1 = Workbooks("Data.xlsm")
Set rngSearch = wb1.Worksheets("Sheet2").Range("B2:B10")
For Each c In wb1.Worksheets("Sheet1").Range("A2:A11")
iRow = WorksheetFunction.Match(c.Value, rngSearch, 0)
c.Offset(1, 4).Value = rngSearch.Offset(iRow, 3).Resize(1, 1).Value
Next c
End Sub
I am trying to determine why the code "code/file attached within" is not returning the values that I need, no luck so far.
My goal is to take the value in A from sheet 1, match it in B from sheet 2 to determine the row number then copy E & F values from the same line "sheet 2" and return it to the corresponding row/column in sheet 1.
I am kindly seeking your assistance to point me in the right direction.
Thank you.
RA
Sub HR_Lookup()
' Look for HR# and copy a specific field
Dim iRow As Long
Dim wb1 As Workbook
Dim c As Range
Dim rngSearch As Range
Set wb1 = Workbooks("Data.xlsm")
Set rngSearch = wb1.Worksheets("Sheet2").Range("B2:B10")
For Each c In wb1.Worksheets("Sheet1").Range("A2:A11")
iRow = WorksheetFunction.Match(c.Value, rngSearch, 0)
c.Offset(1, 4).Value = rngSearch.Offset(iRow, 3).Resize(1, 1).Value
Next c
End Sub