Hi!
I'm a newbie to the list, and a newbie to VB. I found a clip of text that is supposed to do what I want it to, but hasn't been working in my workbook thus far.
from http://www.contextures.com/excelfiles.html#CondFormat -- DataValMultiSelect.zip
(SameCell worksheet)
code looks like this:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngDV As Range
Dim oldVal As String
Dim newVal As String
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
newVal = Target.Value
Application.Undo
oldVal = Target.Value
Target.Value = newVal
If Target.Column = 3 Then
If oldVal = "" Then
'do nothing
Else
If newVal = "" Then
'do nothing
Else
Target.Value = oldVal _
& ", " & newVal
End If
End If
End If
End If
exitHandler:
Application.EnableEvents = True
End Sub
------------
Also, would there be a way to prioritize items in the list so that if, say the first two items are selected, those appear first and second, instead of second and then first?
Thanks much for any advice!!
e
I'm a newbie to the list, and a newbie to VB. I found a clip of text that is supposed to do what I want it to, but hasn't been working in my workbook thus far.
from http://www.contextures.com/excelfiles.html#CondFormat -- DataValMultiSelect.zip
(SameCell worksheet)
code looks like this:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngDV As Range
Dim oldVal As String
Dim newVal As String
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
newVal = Target.Value
Application.Undo
oldVal = Target.Value
Target.Value = newVal
If Target.Column = 3 Then
If oldVal = "" Then
'do nothing
Else
If newVal = "" Then
'do nothing
Else
Target.Value = oldVal _
& ", " & newVal
End If
End If
End If
End If
exitHandler:
Application.EnableEvents = True
End Sub
------------
Also, would there be a way to prioritize items in the list so that if, say the first two items are selected, those appear first and second, instead of second and then first?
Thanks much for any advice!!
e