Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Value
Case Is = 1
Target.Value = "John"
Case Is = 2
Target.Value = "Tom"
End Select
End Sub
this goes into the worksheet module of the affected worksheet.
Not really sure how to make it work for numbers with two preceeding zeros. The downside of this code is that you wont be able to enter either 1 nor 2 in the worksheet.
You could alter it to do those changes only in a desired range:
Private Sub Worksheet_Change(ByVal Target As Range)
set mRange = Range("A1:A20")
if not intersect(mRange,Target) is nothing then
Select Case Target.Value
Case Is = 1
Target.Value = "John"
Case Is = 2
Target.Value = "Tom"
End Select
end if
End Sub
Bookmarks