T
TotallyConfused
In my quest to find examples of how to select Multiple values from drop down
list, I found this code from "Contextures" website on how to do this in Excel
spreadsheet. However, I am using a Userform and want to know how do I
incorporate this into a Userform? Can someone please help me with this? I
am new to Excel code and I apologize for my lack of knowledge. Thank you in
advance for any help you can provide.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo exitHandler
Dim rngDV As Range
If Target.Count > 1 Then GoTo exitHandler
On Error Resume Next
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler
If rngDV Is Nothing Then GoTo exitHandler
If Intersect(Target, rngDV) Is Nothing Then
'do nothing
Else
Application.EnableEvents = False
If Target.Column = 3 Then
If Target.Value = "" Then GoTo exitHandler
If Target.Offset(0, 1).Value = "" Then
Target.Offset(0, 1).Value = Target.Value
Else
Target.Offset(0, 1).Value = _
Target.Offset(0, 1).Value _
& ", " & Target.Value
End If
End If
End If
exitHandler:
Application.EnableEvents = True
End Sub
list, I found this code from "Contextures" website on how to do this in Excel
spreadsheet. However, I am using a Userform and want to know how do I
incorporate this into a Userform? Can someone please help me with this? I
am new to Excel code and I apologize for my lack of knowledge. Thank you in
advance for any help you can provide.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo exitHandler
Dim rngDV As Range
If Target.Count > 1 Then GoTo exitHandler
On Error Resume Next
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler
If rngDV Is Nothing Then GoTo exitHandler
If Intersect(Target, rngDV) Is Nothing Then
'do nothing
Else
Application.EnableEvents = False
If Target.Column = 3 Then
If Target.Value = "" Then GoTo exitHandler
If Target.Offset(0, 1).Value = "" Then
Target.Offset(0, 1).Value = Target.Value
Else
Target.Offset(0, 1).Value = _
Target.Offset(0, 1).Value _
& ", " & Target.Value
End If
End If
End If
exitHandler:
Application.EnableEvents = True
End Sub