Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Don Don is offline
external usenet poster
 
Posts: 487
Default How to setup a list box with multiple selections

I need to set up a list box that will allow multiple selections. I can setup
the box, but can't get a macro to recognize it.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default How to setup a list box with multiple selections

Hi Don,

You possibly know some of the following but if not then the information is
essential to the answer.

Firstly there are 2 types of List Boxes. In xl2007 when inserting controls
you will see them as Form Controls or ActiveX controls. In earlier versions
the form controls are on the Forms Toolbar and the ActiveX controls are on
the Control Toolbox toolbar.

To make property changes to ActiveX controls, you need to be in Design Mode
which is toggled on and off with a button and icon like a blue set square and
a ruler and pencil. When the control is first created, Design mode turns on
by default. Don't forget to turn it off after finishing the design of the
control.

To make multiple selections in a Test Box you will need to have a command
button to run the code after the selections are made. The following code is
for ActiveX type List Boxes and ActiveX type Command Button. To insert the
code, create the ActiveX command button and while in Design Mode, right click
the command button and select View Code and insert the code between the
Private Sub and End Sub lines that are automatically created.

The code is extracted from a previous post by MVP Dave Peterson.

Dim DestCell As Range
Dim iCtr As Long

With Worksheets("sheet1")
Set DestCell = .Range("A1")
End With

With Me.ListBox1
DestCell.Resize(.ListCount, 1).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

--
Regards,

OssieMac


"Don" wrote:

I need to set up a list box that will allow multiple selections. I can setup
the box, but can't get a macro to recognize it.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Allow for multiple selections from a list Doug Excel Worksheet Functions 1 February 18th 09 10:39 PM
multiple selections from drop down list Andyroo Excel Worksheet Functions 4 August 16th 06 06:39 PM
Can List or Combo Box have multiple selections? [email protected] Excel Worksheet Functions 2 April 6th 06 03:41 PM
Excel: Can you allow multiple selections from one list box? tonia_b3 Excel Discussion (Misc queries) 3 February 21st 06 04:32 PM
List box with multiple selections James[_20_] Excel Programming 0 February 25th 04 09:00 PM


All times are GMT +1. The time now is 12:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"