Worksheet event is used.
Sheet 'Data entry' A2:A10 is validated.
Validation list 'list' F1:F10
Worksheet event code for 'Data entry' sheet.
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A2:A10")) Is Nothing Then
If Target = "" Then
Exit Sub
Else
Application.EnableEvents = False
Target.Value = Left(Target.Value, InStr(1, Target.Value, "-") - 1)
Application.EnableEvents = True
End If
End If
End Sub
How to use workheet event the code
Right click on Sheet tab --> view code
Visual Basic (VB) window opens.
Paste the code
Close the VB window.
Save the file as .xlsm
Bookmarks