Multi-select from a dropdown list

P

PaulaG

I have a dropdown list but wish to select more than one item from it - is
this possible?
 
D

Dave Peterson

Not really.

Could you replace it with a listbox -- and allow multiple selections?
 
R

Roger Govier

Hi Paula

Only with code

This code (not written by me) will allow you to make multiple selections
from a data validation cell, and will insert a comma between each
selected value

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngDV As Range
Dim oldVal As String, newVal As String
Dim tr As Long
tr = Target.Row
If Target.Count > 1 Then GoTo exitHandler

On Error Resume Next
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler

If rngDV Is Nothing Then GoTo exitHandler

If Intersect(Target, rngDV) Is Nothing Then
'do nothing
Else
Application.EnableEvents = False
newVal = Target.Value
Application.Undo
oldVal = Target.Value
Target.Value = newVal
If oldVal = "" Then
'do nothing
Else
If newVal = "" Then
'do nothing
Else
Target.Value = oldVal _
& ", " & newVal
End If
End If
End If

exitHandler:
Application.EnableEvents = True
End Sub

It is event code so you need to copy it to the sheet where you have your
cells with Data Validation.

Copy code above
Right click on sheet tab>View Code
Paste code into white pane that appears
Alt+F11 to return to Excel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top