View Single Post
 
Old 01-20-2019, 06:18 AM
alpha alpha is offline Windows 10 Office 2010 64bit
Novice
 
Join Date: Jun 2018
Posts: 18
alpha is on a distinguished road
Default

If your codes and names are on sheet2 in columns A and B, beginning in row 2:
- Copy the code below.
- Rightclick on the sheettab of sheet1 and click "View code".
- Where the cursor is flashing, rightclick and choose "Paste".
- Now you can drop codes in Sheet1 columnB, beginning in B2.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim a As Integer
If Not Intersect(Range("b2:b30"), Target) Is Nothing Then
a = Application.CountIf(Sheets(2).Range("a2:a30"), Target)
If a > 0 Then
Target.Value = Application.VLookup(Target, Sheets(2).Range("a2:b30"), 2, 0)
End If
End If
End Sub

Last edited by alpha; 01-21-2019 at 12:37 AM.
Reply With Quote