Hi, having never used Macros before I wanted to use one to be able to multi-select options from a dropdown list in Column C. Having googled, some kind person had posted the VBA code and I opened the VBA editor, pasted it in and hey presto it worked! (See code below question).
Anyway, I then updated the Dropdown list in my data validation and although the previous rows still allow me to multi-select, the blank rows don't (I updated the drop down box for the entire column from Row 2 downwards to about row 1100, although only 600 currently in use. What have I done wrong? It seems like the Macro is still working for some rows but not for the new ones?
Thanks in hope.
Colette
Private Sub Worksheet_Change(ByVal Target As Range)
'Code by Sumit Bansal from https://trumpexcel.com
' To Select Multiple Items from a Drop Down List in Excel
Dim Oldvalue As String
Dim Newvalue As String
On Error GoTo Exitsub
If Target.Column = 3 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
Anyway, I then updated the Dropdown list in my data validation and although the previous rows still allow me to multi-select, the blank rows don't (I updated the drop down box for the entire column from Row 2 downwards to about row 1100, although only 600 currently in use. What have I done wrong? It seems like the Macro is still working for some rows but not for the new ones?
Thanks in hope.
Colette
Private Sub Worksheet_Change(ByVal Target As Range)
'Code by Sumit Bansal from https://trumpexcel.com
' To Select Multiple Items from a Drop Down List in Excel
Dim Oldvalue As String
Dim Newvalue As String
On Error GoTo Exitsub
If Target.Column = 3 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