Hi all,
This is my first time posting a thread but a few years following yours.
I have the following code which I can't make it work. It works when its refer to a single cell but it does't works when I use a named range. I have a named range "TGCEne" in the active worksheets with data validation from a named range "CodeExp" from another worksheet. Could you please let me know what I am doing wrong?
I would appreciate your help.
Many thanks from Madrid
This is my first time posting a thread but a few years following yours.
I have the following code which I can't make it work. It works when its refer to a single cell but it does't works when I use a named range. I have a named range "TGCEne" in the active worksheets with data validation from a named range "CodeExp" from another worksheet. Could you please let me know what I am doing wrong?
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim strInput As String
'assumed name range = "CodeExp" from worksheet "Sheets1" where data to validate list are.
If Target.Address <> Range("CodeExp") Then Exit Sub
If Target.Value = "" Then Exit Sub
'find the hyphen and extract the required text
strInput = Trim(Mid(Target.Value, 1, Application.Find("-", Target.Value) - 1))
'disable events before writing to worksheet
On Error Resume Next
Application.EnableEvents = False
Target.Value = strInput
Application.EnableEvents = True
End Sub
I would appreciate your help.
Many thanks from Madrid