Option Explicit
Sub srchCpy()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim searchValue As Variant
Dim resultValue As Variant
Dim lastRow1 As Long, lastRow2 As Long
Dim searchRange As Range, foundCell As Range
Dim i As Long
' Set references to the worksheets
Set ws1 = ThisWorkbook.Worksheets("Sheet1")
Set ws2 = ThisWorkbook.Worksheets("Sheet2")
' Get the last row in each worksheet
lastRow1 = ws1.Cells(ws1.Rows.Count, "A").End(xlUp).Row
lastRow2 = ws2.Cells(ws2.Rows.Count, "A").End(xlUp).Row
' Set the range to search in Sheet2
Set searchRange = ws2.Range("A1:A" & lastRow2)
' Loop through each cell in column A of Sheet1
For i = 2 To lastRow1
searchValue = ws1.Cells(i, "A").Value
' Search for the value in Sheet2 column A
Set foundCell = searchRange.Find(What:=searchValue, LookIn:=xlValues, LookAt:=xlWhole)
If Not foundCell Is Nothing Then
' If found, copy the corresponding value from column B
resultValue = foundCell.Offset(0, 1).Value
Else
' If not found, set the result to empty
resultValue = ""
End If
' Write the result to column B of Sheet1
ws1.Cells(i, "B").Value = resultValue
Next i
End Sub