ExcelHelpNeeded99
New Member
- Joined
- Oct 6, 2017
- Messages
- 13
Can anyone help me see where Im going wrong. I only want multi select dropdown lists in columns 10,22,46,47,48, I need the rest to be single select or text only. I used the below vba code and altered it for my columns but every column is multi select. I am new to this forum and appreciate the help. Thanks
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Updated: 2016/4/12
Dim xRng As Range
Dim xValue1 As String
Dim xValue2 As String
If (Target.Column = 10 Or Target.Column = 22 Or Target.Column = 46 Or Target.Column = 47 Or Target.Column = 48) 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
If xValue1 = xValue2 Or _
InStr(1, xValue1, "; " & xValue2) Or _
InStr(1, xValue1, xValue2 & ";") Then
Target.Value = xValue1
Else
Target.Value = xValue1 & "; " & xValue2
End If
End If
End If
End If
Application.EnableEvents = True
End Sub
[Code/]