Hi all,
I would like to be able to select multiple values from a cell data validation list dropdown which are then entered into the cell within the chosen column. This is the code I have come up with which works but it sometimes gets a runtime error and disables the code which then requires me to re-open the spreadsheet to get it working again. I welcome any ideas on how to prevent this in my code.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim oldVal As String
Dim newVal As String
Dim sComments As String
If Target.Count > 1 Then Exit Sub
If Target.Column = 10 Then
On Error GoTo exit_Click_Err
'If Target.Column <> 100 Then
newVal = Target.Value
If newVal <> "" Then
Application.EnableEvents = False
Application.Undo
Else
End If
oldVal = Target.Value
If InStr(oldVal, newVal) = 0 Then
Target.Value = IIf(oldVal = "", "", oldVal) & ";" & newVal
End If
Application.EnableEvents = True
End If
exit_Click_Exit:
Exit Sub
exit_Click_Err:
'MsgBox Error$
Resume exit_Click_Exit
End Sub
For Info, the error normally occurs when I select the cell and hit delete key to delete any entries I have made and the error is : runtime error 1004 , method 'UNDO' of object '_Application failed'
Thanks
Skoolz
Bookmarks