Excel newbie here. I've seen a few threads on this but can't quite get it to work on my end. I originally used the code here: How to Make Multiple Selections in an Excel Drop-Down list and tried it on a test column. The only thing i changed was A2 in line 6 to Q2 to match my column. It worked perfectly! But my workbook has a total of 14 worksheets, each sheet has the exact same content (each sheet represents a different city in my case). So then I went in and repeated the data-validation in all sheets and then opened up the VBE editor and went sheet by sheet, posting that code into the VBE editor. Saved, exited. But now when I try to make multiple selections on any of the sheets, it doesn't work. I can only assume I did it wrong as far as having it apply to multiple sheets. But I just can't seem to figure it out. Help?
TLDR; I need to be able to make multiple selections in a single drop down list... on every sheet in my workbook.
VBA code used:
TLDR; I need to be able to make multiple selections in a single drop down list... on every sheet in my workbook.
VBA code used:
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("Q2")) 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 & vbNewLine & Newvalue
Else:
Target.Value = Oldvalue
End If
End If
End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub