ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   multiple selection in combo box (https://www.excelbanter.com/excel-discussion-misc-queries/126775-multiple-selection-combo-box.html)

jen_writer

multiple selection in combo box
 
Hello,
I'd like to use a combo box or drop-down list for selecting from a list.
However, I need to be able to select multiple items from the list. Is there a
way to set this up (e.g. hold the ctrl key and select)?

thank you
Jen

Dave Peterson

multiple selection in combo box
 
How about using a listbox from the control toolbox toolbar and a commandbutton
from that same toolbar.

Then you can use code like this to retrieve the selected items from the listbox:

Option Explicit
Private Sub CommandButton1_Click()

Dim iCtr As Long
Dim DestCell As Range

Set DestCell = Me.Range("a2")

With Me.ListBox1
DestCell.Resize(.ListCount).ClearContents
For iCtr = 0 To .ListCount - 1
If .Selected(iCtr) Then
DestCell.Value = .List(iCtr)
Set DestCell = DestCell.Offset(1, 0)
End If
Next iCtr
End With

End Sub

Double click on the commandbutton and you'll see where this code goes.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

jen_writer wrote:

Hello,
I'd like to use a combo box or drop-down list for selecting from a list.
However, I need to be able to select multiple items from the list. Is there a
way to set this up (e.g. hold the ctrl key and select)?

thank you
Jen


--

Dave Peterson

Gord Dibben

multiple selection in combo box
 
Debra Dalgleish has a sample workbook with a combo-box that allows multiple
selections.

DV0017 - Select Multiple Items from Dropdown List-- Select multiple items from a
dropdown list; an event macro stores selections in adjacent cell, or in same
cell.

http://www.contextures.on.ca/excelfiles.html#DataVal


Gord Dibben MS Excel MVP

On Fri, 19 Jan 2007 12:15:26 -0800, jen_writer
wrote:

Hello,
I'd like to use a combo box or drop-down list for selecting from a list.
However, I need to be able to select multiple items from the list. Is there a
way to set this up (e.g. hold the ctrl key and select)?

thank you
Jen




All times are GMT +1. The time now is 06:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com