Hello,

I have worked on the Vlookup VBA code. Its working fine.

BUT, I want this code to get applied for the whole Row till last available data.

I want below code to be get applied for the whole column "R" till last available data in the row.


Sub Vlookup()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim srchres As Variant

Set ws1 = Workbooks("Trvl port 1").Sheets("EF")
Set ws2 = Workbooks("TRVL DK").Sheets("Sheet1 (2)")

On Error Resume Next
srchres = Application.WorksheetFunction.Vlookup(ws2.Range("A2"), ws1.Range("A1:V65536"), 18, False)
On Error GoTo 0
If (IsEmpty(srchres)) Then
ws2.Range("R2").Formula = CVErr(xlErrNA) ' Use whatever you want
Else
ws2.Range("R2").Value = srchres
End If

End Sub