Replace value from validation list with a number using VBA in Microsoft Excel



The selection from a validity list in column D shall be replaced by a number. Works only with XL9 and higher.


Place the code below into the This Workbook module.

Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.Column <> 4 Then Exit Sub
   Application.EnableEvents = False
   Target.Value = WorksheetFunction.VLookup(Target.Value, Range("A1:B12"), 2, 0)
   Application.EnableEvents = True
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>