Multiple entries from a drop down list


T

Tech_Wolf

I need to be able to select multiple entries from a drop down tab that
references a named list elsewhere in the workbook. I am able to get the drop
down tab to funtion, however it refuses to project those selections into a
different cell, or select multiple entries from the list. I have tried
various sample codes, as suggested in other posts, however when I copy that
code over to my spreadsheet, it does not work. I can provide the specific
files if need
be. Any suggestions?
Heres the code I'm currently using

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo exitHandler

Dim rngDV As Range
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
If Target.Column = 3 Then
If Target.Value = "" Then GoTo exitHandler
If Target.Offset(0, 1).Value = "" Then
Target.Offset(0, 1).Value = Target.Value
Else
Target.Offset(0, 1).Value = _
Target.Offset(0, 1).Value _
& ", " & Target.Value
End If
End If
End If

exitHandler:
Application.EnableEvents = True

End Sub
 
Ad

Advertisements

P

Patrick Molloy

I assume you're using an ActiveX listbox control and it has multiselect
enabled

the example resizes an area on the sheet, starting at C1 and each time an
item in the listbox is selected, the code will repopulate the table

so on the sheet's code page (right-click the sheet tab and select View Code
from the popup) paste this in:


Option Explicit
Private Sub ListBox1_Change()
Dim i As Long
Dim os As Long
With Range("C1")
.Resize(ListBox1.ListCount).ClearContents
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
.Offset(os) = ListBox1.List(i)
os = os + 1
End If
Next
End With
End Sub
 

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

Top