as an option (if the sort of columns A and B are allowed)
Sub ert()
Application.ScreenUpdating = False
Columns(3).Insert
With Range("A1:B" & Cells(Rows.Count, 1).End(xlUp).Row)
.Sort Key1:=.Cells(1, 1), Order1:=xlAscending, _
Key2:=.Cells(1, 2), Order2:=xlDescending, _
Header:=xlNo, MatchCase:=False
.Offset(, 2).Resize(, 1).FormulaR1C1 = "=VLOOKUP(RC[-2]," & .Address(, , xlR1C1) & ",2,0)"
.Columns(2).Value = .Offset(, 2).Resize(, 1).Value
End With
Columns(3).Delete
Application.ScreenUpdating = True
End Sub
Bookmarks