From c840705cf17a4cf4de0b5afb27d9e3f97ea46a8b Mon Sep 17 00:00:00 2001 From: Shai Rado Date: Wed, 26 Apr 2017 20:51:05 +0300 Subject: [PATCH] Removed some un-necessary lines Removed the `If Intersect` and used `If Not Intersect`, this way you don't need to check 1 line, and go to the `Else`, just go directly to the `If Not` --- multi-select.vb | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/multi-select.vb b/multi-select.vb index 956e892..3dc41aa 100644 --- a/multi-select.vb +++ b/multi-select.vb @@ -10,23 +10,17 @@ 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 Target.Column = 1 Then - If oldVal = "" Then - Else - If newVal = "" Then - Else - Target.Value = oldVal _ - & ", " & newVal - End If +If Not Intersect(Target, rngDV) Is Nothing Then + Application.EnableEvents = False + newVal = Target.Value + Application.Undo + oldVal = Target.Value + Target.Value = newVal + If Target.Column = 1 Then + If oldVal <> "" And newVal <> "" Then + Target.Value = oldVal & ", " & newVal + End If End If - End If End If exitHandler: