Hi All,
I am using the below code to use excel list for multiple selections.
if i select again same value i need to remove the value ( Deselect) . can you please help.
I am using the below code to use excel list for multiple selections.
if i select again same value i need to remove the value ( Deselect) . can you please help.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Oldvalue As String
Dim Newvalue As String
If Target.Address <> "$E$57" Then Exit Sub
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then Exit Sub
If Target.Value = "" Then Exit Sub
Application.EnableEvents = False
On Error GoTo Exitsub
If Target.Value = "Multiple List" Then Target.Value = vbNullString
Newvalue = Target.Value
Application.Undo
Oldvalue = Target.Value
If Oldvalue = "" Then
Target.Value = Newvalue
Else
If InStr(1, Oldvalue, Newvalue) = 0 Then
Target.Value = Oldvalue & ", " & Newvalue
Else
Target.Value = Oldvalue
End If
End If
Application.EnableEvents = True
Exit Sub
Exitsub:
Application.EnableEvents = True
End Sub