Multiple list selections on new line

M3L333

New Member
Joined
Jul 31, 2018
Messages
15
I have a list I have created under data validation. I need the list to allow multiple selections with the new selection beginning on a new line. I have watched You Tube Video's and played around but can't seem to get this code right. I am a novice excel user.

When I use the data validation list now I get a pop up that say's "Variable not defined", and highlights the word NewValue in my code. Help Please!!



Option Explicit


Private Sub Worksheet_Change(ByVal Target As Range)
Dim oldVal As String
Dim newVal As String


On Error GoTo Exitsub
If Target.Column = 3 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
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
That's because you haven't declared a variable called "NewValue", you've declared it as "Newval".
The same is true for "OldValue"
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top