blanch2009
New Member
- Joined
- Feb 24, 2009
- Messages
- 6
Hello.
I'm using the code below in a worksheet:
I found the tutorial on YouTube and the dropdown list feature multiple select of values.
It works perfectly!! Except for one thing. When I click to protect the sheet, the multiple selection feature goes away. I'm able
to select a single value but not multiple.
I took the check mark off on the Select Locked Cells under the Protect tab.
I did this to all input cells so I can tab through the sheet and not have tab into an empty cell.
I hope I'm explaining myself clearly.
This is my first attempt in VBA.
If I unprotect the sheet then the tab through doesn't work.
Any help would really be appreciated and thank you in advance.
Don
Option Explicit
I'm using the code below in a worksheet:
I found the tutorial on YouTube and the dropdown list feature multiple select of values.
It works perfectly!! Except for one thing. When I click to protect the sheet, the multiple selection feature goes away. I'm able
to select a single value but not multiple.
I took the check mark off on the Select Locked Cells under the Protect tab.
I did this to all input cells so I can tab through the sheet and not have tab into an empty cell.
I hope I'm explaining myself clearly.
This is my first attempt in VBA.
If I unprotect the sheet then the tab through doesn't work.
Any help would really be appreciated and thank you in advance.
Don
Option Explicit
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Code by Sumit Bansal from [URL='https://trumpexcel.com']Online Excel Tips & Tutorials[/URL]
' To Select Multiple Items from a Drop Down List in Excel
Dim Oldvalue As String
Dim Newvalue As String
Application.EnableEvents = True
On Error GoTo Exitsub
If Target.Address = "$I$5" Or Target.Address = "$L$11" 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 & ", " & Newvalue
Else:
Target.Value = Oldvalue
End If
End If
End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub
Last edited by a moderator: