I am working with the following code from https://trumpexcel.com/select-multiple-items-drop-down-list-excel/
I want to change it so that Excel only runs Column A (1). What edit(s) do I need to make?
The macro is to allow multiple selections from a data validation dropdown. I'm getting an error, I think because I have other data validations running on the same sheet, which is formatted as a table.
Data Validation Error is Field Type Information / A2 / Restriction: Value must match one of the listed items
Private Sub Worksheet_Change(ByVal Target As Range)
'Code by Sumit Bansal from https://trumpexcel.com
' To make mutliple selections in a Drop Down List in Excel
Dim Oldvalue As String
Dim Newvalue As String
On Error GoTo Exitsub
If Target.Column = 1 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
Target.Value = Oldvalue & ", " & Newvalue
End If
End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub
If Target.Column = 1already restricts it to ColA. If you're getting an error it's useful to describe what the error is and where and when it occurs.Targetis a multi-cell rangel when you get the error, because the code does not at all handle multi-cell range change events.