I need a macro using VLOOKUP to compare data in Sheet1 Column B with Sheet2 Column C. If they match, I want to have the value in Sheet1 Column E to be copied to Sheet2 Column D.
I found this macro online and have modified it but I dont think I have the VLOOKUP formula correct. I have that part in red. Please help!
[code]
Sub PlaceVlookup()
'Determine last row based on Sheet 1 Column B
lastRow = Sheets(1).Range("B" & Rows.Count).End(xlUp).Row
'Insert formula using lastRow variable
Sheets(2).Range("D1:D" & lastRow).FormulaR1C1 = _
"=VLOOKUP(RC[1],Sheet2!RC[3]:R[" & lastRw - 1 & "]C[2],3,0)"'Copy/PasteSpecial Values
With Sheets(2).Range("D1:D" & lastRow)
.Copy
.PasteSpecial Paste:=xlPasteValues
End With
End Sub
[code]
Bookmarks