Try the following code:
Dim fRange As Range
For Each cell In Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
Set fRange = Sheets("Sheet2").Columns("N:N").Find(cell.Value)
If Not fRange Is Nothing Then
If cell.Offset(0, 10).Value = fRange.Offset(0, -2).Value Then
cell.Offset(0, 8).Value = fRange.Offset(0, -4).Value
How to implement and run a code:
- From Excel hit Alt + F11 to open the “Microsoft Visual Basic” window.
- Go to the top menu in the newly opened window > Insert > Module.
- Paste the code in the big white field.
- You can now close this window.
- Back at Excel, hit Alt + F8 to display the available macro’s.
- Double-click the macro you wish to run.
NOTE: macro’s cannot be reversed using the blue arrows. Always make sure you save your file (or create a back up to be entirely sure) before running a code, so you can re-open your file if something unforeseen happens or you want to go back to the situation before the code was run.
And below is a link where you can find the workbook similating your scenario.
Group letters D and F are found on sheet2 but only group letter D has a matching description, thus the value 333 will be copied over to sheet1.
Here is the link: