excelbytes
Active Member
- Joined
- Dec 11, 2014
- Messages
- 296
- Office Version
- 365
- Platform
- Windows
I have the following data:

I want to create a drop down list with the items in column "C", but when an item is selected, I only want it to show the 2 letter code as shown in column "A". I found this code:
But I can't get it to work. The dropdown list is on a worksheet called 'Tools" and the codes and descriptions are on a worksheet called "Data".
Thanks,

I want to create a drop down list with the items in column "C", but when an item is selected, I only want it to show the 2 letter code as shown in column "A". I found this code:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A2:A30")) Is Nothing Then Exit Sub 'Addresses of the cells with the dropdown
'Turn off events to keep out of loops
Application.EnableEvents = False
'Change the "C1:D10" in the next line to the address of your list
Target.Value = Application.VLookup(Target.Value, Range("A2:B8"), 2, False)
'Turn events back on to get ready for the next change
Application.EnableEvents = True
End Sub
But I can't get it to work. The dropdown list is on a worksheet called 'Tools" and the codes and descriptions are on a worksheet called "Data".
Thanks,