Hi -
I've watched multiple videos and set up a data validation list that I would like the user to be able to select more than one option from. The data validation list is tied to cell F11. The code I'm using is listed below. When I save and try to select multiple options the system behaves like there is no code at all, overwriting each selection with the newly selected and not allowing multiple. Thoughts on what I'm doing wrong?
I've got the following code in my VBA:
I've watched multiple videos and set up a data validation list that I would like the user to be able to select more than one option from. The data validation list is tied to cell F11. The code I'm using is listed below. When I save and try to select multiple options the system behaves like there is no code at all, overwriting each selection with the newly selected and not allowing multiple. Thoughts on what I'm doing wrong?
I've got the following code in my VBA:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Oldvalue As String
Dim Newvalue As String
Application.EnableEvents = True
On Error GoTo Exitsub
If Target.Address = "$F$11" Then
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
GoTo Exitsub
Else: If Target.Value = "" Then GoTo Exitsub Else
Application.EnableEvents = False
Newvalue = Target.Value
Application.Undo
Oldvalue = Target.Value
If Oldvalue = "" Then
Target.Value = Newvalue
Else
If InStr(1, Oldvalue, Newvalue) = 0 Then
Target.Value = Oldvalue & vbNewLine & Newvalue
Else:
Target.Value = Oldvalue
End If
End If
End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub
Last edited by a moderator: