hi
I'm using a macro (below) to allow a user to select more than one value within a dropdown list, HOWEVER, i want it to apply to only ONE dropdown list/cell, and not every dropdown list/cell in the worksheet.
I've tried multiple ways of exiting the macro, when not in that ONE cell, but none of my efforts have worked.
Here's the macro i'm using. Thanks in advance,
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xRng As Range
Dim xValue1 As String
Dim xValue2 As String
If Target.Count > 1 Then Exit Sub
On Error Resume Next
Set xRng = Cells.SpecialCells(xlCellTypeAllValidation)
If xRng Is Nothing Then Exit Sub
Application.EnableEvents = False
If Not Application.Intersect(Target, xRng) Is Nothing Then
xValue2 = Target.Value
Application.Undo
xValue1 = Target.Value
Target.Value = xValue2
If xValue1 <> "" Then
If xValue2 <> "" Then
Target.Value = xValue1 & ", " & xValue2
End If
End If
End If
Application.EnableEvents = True
End Sub
I'm using a macro (below) to allow a user to select more than one value within a dropdown list, HOWEVER, i want it to apply to only ONE dropdown list/cell, and not every dropdown list/cell in the worksheet.
I've tried multiple ways of exiting the macro, when not in that ONE cell, but none of my efforts have worked.
Here's the macro i'm using. Thanks in advance,
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xRng As Range
Dim xValue1 As String
Dim xValue2 As String
If Target.Count > 1 Then Exit Sub
On Error Resume Next
Set xRng = Cells.SpecialCells(xlCellTypeAllValidation)
If xRng Is Nothing Then Exit Sub
Application.EnableEvents = False
If Not Application.Intersect(Target, xRng) Is Nothing Then
xValue2 = Target.Value
Application.Undo
xValue1 = Target.Value
Target.Value = xValue2
If xValue1 <> "" Then
If xValue2 <> "" Then
Target.Value = xValue1 & ", " & xValue2
End If
End If
End If
Application.EnableEvents = True
End Sub