Hi
Put the following values in the range I7:J9
101,Apple
102,Orange
409,Grape
Give that range a defined name of LURng.
Private Sub btnReplace_Click()
Worksheets("Sheet1").Range("B3").Activate
Dim MyCell As Range
For Each MyCell In Range("C3:C10")
If MyCell <> "" Then
If Left(MyCell, 1) = "A" Then
MyCell.Offset(0, -1).Value = WorksheetFunction.VLookup(Val(Mid(MyCell, 3, 3)), Range("LURNG"), 2, False)
Else
MyCell.Offset(0, -1).Value = WorksheetFunction.VLookup(Val(Mid(MyCell, 2, 3)), Range("LURNG"), 2, False)
End If
End If
Next
End Sub
HTH
rylo
Bookmarks