Hi,
Came across this code to select multiple items from dropdown list.It does select multiple items seperated by ";" for second\third item.
But when cell is double clicked to edit\add name for another item. It copies the old items and adds them again.
ex. : selected Apples and oranges from dropdown
Double clicked cell to add/edit another item not in list (grapes) and the output shown below
apple;orange; apple;orange;grapes ( note:it copied apple;orange twice in cell)
Need help to modify code below (to show items once when new added/edited/deleted items)
Help is really Appreciated !!!!!
Came across this code to select multiple items from dropdown list.It does select multiple items seperated by ";" for second\third item.
But when cell is double clicked to edit\add name for another item. It copies the old items and adds them again.
ex. : selected Apples and oranges from dropdown
Double clicked cell to add/edit another item not in list (grapes) and the output shown below
apple;orange; apple;orange;grapes ( note:it copied apple;orange twice in cell)
Need help to modify code below (to show items once when new added/edited/deleted items)
Help is really Appreciated !!!!!
Code:
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
Else
Application.EnableEvents = False
newVal = Target.Value
Application.Undo
oldVal = Target.Value
Target.Value = newVal
If oldVal = "" Then
Else
If newVal = "" Then
Else
Target.Value = oldVal & "; " & newVal
End If
End If
End If
exitHandler:
Application.EnableEvents = True
End Sub