Sometime ago, I posted a question in this community about truncating the column so that only the code will be displayed in the column with a dropdown list -- meaning the description will be omitted. One of the suggestions was to hide the description with
the same color font as the background. This was okay but a colleague showed me a template that she was using and the macro was working as expected - totally dropping / chopping off the description without changing the color of the fonts. Unfortunately,
the person who created that template is now unreachable.
I tried copying the codes used in that template and applied those in my file but it is not working. Do you think I am missing anything here? Do I need to do any Text to column function to make these codes work? Below are the codes used:
Module:
Public Sub extractCode(ByVal Target As Range)
If Target.Count <= 1 Then
If Target.Offset(-Target.Row + 2, 0).Value > 0 Then
If Trim(Target.Value) <> Trim(Left(Target.Value, Target.Offset(-Target.Row + 2, 0).Value)) Then
Target.Value = Left(Target.Value, Target.Offset(-Target.Row + 2, 0).Value)
End If
End If
End If
End Sub
Worksheet - Change:
Private Sub Worksheet_Change(ByVal Target As Range)
extractCode Target
End Sub
Below is the output - I would want the same for my template -- only codes are recorded.
Hoping for the community's help once again.
Thanks in advance!