Hi all,
I am trying to understand VBA as I am working on my document. I am getting stuck at the following issue:
For two cells (D43 and D56)I want to be able to deselect values from a multi-select dropdown which presents each value below the other. My current code is as following (without deselect):
How do I introduce the deselect function in here? Your help is much appreciated!
I am trying to understand VBA as I am working on my document. I am getting stuck at the following issue:
For two cells (D43 and D56)I want to be able to deselect values from a multi-select dropdown which presents each value below the other. My current code is as following (without deselect):
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Oldvalue As String
Dim Newvalue As String
Application.EnableEvents = True
On Error GoTo Exitsub
If Not Intersect(Target, Range("D56", "D43")) Is Nothing Then
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
GoTo Exitsub
Else: If Target.Value = "" Then GoTo Exitsub Else
Application.EnableEvents = False
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 & vbNewLine & Newvalue
Else:
Target.Value = Oldvalue
End If
End If
End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub
How do I introduce the deselect function in here? Your help is much appreciated!