Sub findCellVal()
Dim c As Range
Sheet1.Activate
Dim ra As Range
Dim lr As Long
lr = Sheet2.Cells(Rows.Count, 4).End(xlUp).Row
Set ra = Sheet3.Range("A:D")
For i = 2 To lr
Sheet3.Activate
Set ra = Cells.Find(what:=Sheet3.Range("D2"), LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
If ra Is Nothing Then
MsgBox "not found"
Else
Sheet2.Range("E2") = ra.Value
End If
Next i
End Sub
Apple | Apple | ||
Banana | Banana | ||
Cherry | Cherry | ||
Orange | Orange | ||
Avo | Avo | ||
Peanuts | Peanuts |
This is Sheet 3 <tbody> [TD="class: xl66"]A | |||||
The aim is to use the data in Column D in Sheet2 to find that same value in sheet 3 and paste it to Column E in Sheet 2. HTH | |||||
Apple | ||||
Peanuts | ||||
Avo | ||||
Orange | ||||
Banana | ||||
Sub findCellVal()
Dim c As Range, f As Range
For Each c In Sheet2.Range("D2", Sheet2.Range("D" & Rows.Count).End(xlUp))
Set f = Sheet3.Cells.Find(c, , xlValues, xlWhole)
If Not f Is Nothing Then
c.Offset(, 1).Value = c.Value
Else
c.Offset(, 1).Value = "Not found"
End If
Next
End Sub
Would it be possible to add the Cell Address of the Values found in sheet 3 to say Column F in sheet 2?
c.Offset(, 1).Value = c.Value
c.Offset(, 2).Value = c.Address