ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   MULTIPLE SELECTION !! (https://www.excelbanter.com/excel-programming/427915-multiple-selection.html)

Jay Dean

MULTIPLE SELECTION !!
 
Hello !

I have a combobox on a userform and it works fine. I need a macro that
will allow me to select multiple items in the dropdown list. Is this
possible at all?

Any help would be appreciated.

Thanks!
Jay



*** Sent via Developersdex http://www.developersdex.com ***

Rick Rothstein

MULTIPLE SELECTION !!
 
Not completely sure, but I don't think it is possible to do that with a
ComboBox. Out of curiosity, if the user selected two or three items in your
ComboBox, what would you display in the text field... the first item? If so,
how would the user know there were other items selected and they were only
looking at one of them?

--
Rick (MVP - Excel)


"jay dean" wrote in message
...
Hello !

I have a combobox on a userform and it works fine. I need a macro that
will allow me to select multiple items in the dropdown list. Is this
possible at all?

Any help would be appreciated.

Thanks!
Jay



*** Sent via Developersdex http://www.developersdex.com ***



FSt1

MULTIPLE SELECTION !!
 
hi
rick is right. combo boxes don't have multiselect properties. but a list box
does. so you might want to consider that.
but a disadvantage would be that, depending on the size of you list, this
might casue a redesign of your form. and the codeing might be a tad trickier.
but that just depends on how great your need for multiselect capabilities is.

regards
FSt1

"jay dean" wrote:

Hello !

I have a combobox on a userform and it works fine. I need a macro that
will allow me to select multiple items in the dropdown list. Is this
possible at all?

Any help would be appreciated.

Thanks!
Jay



*** Sent via Developersdex http://www.developersdex.com ***


Dave Peterson

MULTIPLE SELECTION !!
 
If you want the user to select multiple items, use a listbox.

jay dean wrote:

Hello !

I have a combobox on a userform and it works fine. I need a macro that
will allow me to select multiple items in the dropdown list. Is this
possible at all?

Any help would be appreciated.

Thanks!
Jay

*** Sent via Developersdex http://www.developersdex.com ***


--

Dave Peterson

Jay Dean

MULTIPLE SELECTION !!
 
Rick, FSt1, and Dave -

Okay, if I use a listbox like you suggested and the user selects
multiple items, I need a mcro that will concatenate the selected items
into one string, maybe, store it in a string variable.

For example: Dim Mylist as String.
If a user selects 4 items in the list being: "I like" (1st slection),
"studying" (2nd selection), "vba every" (3rd selection), and "other day"
(4th selection), then
Mylist should contain "I like studying vba every other day"

**Please note that the number of selections 4 used in the above example
is just an example. In reality, the user may select 0 items, 1 item, 2
items, 3 items, 4 itmes, 5 items,... etc.

Any help would be appreciated.
Thanks
Jay



*** Sent via Developersdex http://www.developersdex.com ***

Rick Rothstein

MULTIPLE SELECTION !!
 
Try code something like this...

Dim X As Long
Dim CombinedText As String
With ListBox1
For X = 0 To .ListCount - 1
If .Selected(X) Then
CombinedText = CombinedText & " " & .List(X)
End If
Next
End With
' CombinedText now has the selected items from ListBox1
' concatenated together with a blank space between items

If you need this combined text in other procedures, then the CombinedText
variable should probably be Dim'med in a Module so it is global.

--
Rick (MVP - Excel)


"jay dean" wrote in message
...
Rick, FSt1, and Dave -

Okay, if I use a listbox like you suggested and the user selects
multiple items, I need a mcro that will concatenate the selected items
into one string, maybe, store it in a string variable.

For example: Dim Mylist as String.
If a user selects 4 items in the list being: "I like" (1st slection),
"studying" (2nd selection), "vba every" (3rd selection), and "other day"
(4th selection), then
Mylist should contain "I like studying vba every other day"

**Please note that the number of selections 4 used in the above example
is just an example. In reality, the user may select 0 items, 1 item, 2
items, 3 items, 4 itmes, 5 items,... etc.

Any help would be appreciated.
Thanks
Jay



*** Sent via Developersdex http://www.developersdex.com ***



Jay Dean

MULTIPLE SELECTION !!
 

Thank you Rick...Your code works beautifully!!!
One more thing. After my listbox loads its values, it displays 6 items
at a time (per scroll). Is there a way I can increase the number of
items it dsiplays in the window from 6 to about 10?

I typically use the "ListRows" property for comboboxes, but listboxes
don't give me that option.

Thanks!
Jay


*** Sent via Developersdex http://www.developersdex.com ***

Rick Rothstein

MULTIPLE SELECTION !!
 
You only have two choices as far as I can see... either make the ListBox
taller or make the Font Size smaller (although doing the latter might make
the text too small to be read).

--
Rick (MVP - Excel)


"jay dean" wrote in message
...

Thank you Rick...Your code works beautifully!!!
One more thing. After my listbox loads its values, it displays 6 items
at a time (per scroll). Is there a way I can increase the number of
items it dsiplays in the window from 6 to about 10?

I typically use the "ListRows" property for comboboxes, but listboxes
don't give me that option.

Thanks!
Jay


*** Sent via Developersdex http://www.developersdex.com ***



Jay Dean

MULTIPLE SELECTION !!
 

Thanks, Rick ! I appreciate the help.
I have redefined the scope of the problem, and implemented the solution
using a combobox, a listbox, and an activeX command. It works great.
Your inputs have saved me a lot of time.

Thanks again!
Jay



*** Sent via Developersdex http://www.developersdex.com ***


All times are GMT +1. The time now is 02:03 PM.

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