Hello. I am using the following VBA code which created multi select, comma separated in specific columns, however I also want the option to be able to deselect values you have already selected rather than having to delete all the values in the cell and having to start again, can some please help? Thank you so much for any help offered, I'm completely stuck.
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 Not Intersect(Target, Range("I:I,J:J,K:K,L:L,W:W,X:X,AI:AI,AT:AT,AU:AU,AV:AV,AW:AW,BA:BA,BB:BB,BC:BC")) Is Nothing 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 & "," & Newvalue
Else:
Target.Value = Oldvalue
End If
End If