The code below is taken from VBA vlookup reference in different sheet, but having small changes as I tried to adjusted to my own needs. Short, the vlookup code needs to looks in Sheet 1 - column A - starting from cell A4 until the last entry row, verifies if the existing data is in Sheet 2 - column G and if yes, take the value next to it from column I, go to Sheet 1 and paste that in column B right next to its specific value. However, my approach doesn't work. Any help will be must appreciated!
Sub vlookupB()
Dim vlookup As Variant
Dim lastrow As Long
Dim ws As Worksheet
' i tried to set this in order to take into consideration the last entry from column A.
Set ws = Sheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
On Error Resume Next
vlookup = Application.WorksheetFunction.vlookup(ws.Range("A4" & lastrow), _ 'start from A4 until its last entry from the column
Worksheets("Sheet2").Range("G7:I"), 3, False)
On Error GoTo 0
If IsEmpty(vlookup) Then
' do nothing
End If
Range("B4:B") = vlookup
' paste in column B from sheet1 starting from row B4 until the last entry I have in column A.
' so if for e.g. column A has entries until A200, then it should paste the value until B200 - of course, if the value is found in sheet2
End Sub