Hello!
I'm new to the VBA world and am running into an issue. I used the below code to get multiple selections from drop downs in multiple columns, but when the sheet is protected I'm only able to select one selection from the drop down. I've tried combing through the posts and Google, but nothing seems to be quite right for this code I'm using or it just does not compute with my brain. Any and all help would be MASSIVELY appreciated!
I'm new to the VBA world and am running into an issue. I used the below code to get multiple selections from drop downs in multiple columns, but when the sheet is protected I'm only able to select one selection from the drop down. I've tried combing through the posts and Google, but nothing seems to be quite right for this code I'm using or it just does not compute with my brain. Any and all help would be MASSIVELY appreciated!
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Code by Sumit Bansal from https://trumpexcel.com
' To allow multiple selections in a Drop Down List in Excel (without repetition)
Dim Oldvalue As String
Dim Newvalue As String
Application.EnableEvents = True
On Error GoTo Exitsub
If Target.Column = 9 Or Target.Column = 17 Or Target.Column = 18 Or Target.Column = 19 Or Target.Column = 20 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
End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub