ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multiselect Listbox/ command button (https://www.excelbanter.com/excel-programming/389797-multiselect-listbox-command-button.html)

C Wilson

Multiselect Listbox/ command button
 
I have a multiselect listbox where users can select different options that
will eventually be graphed. There's is no code for the list options. I used
the properties boxes for the listbox. I want the user to be able to press a
command button after they've finished their selections to graph what they've
selected. Will I need to create a list for the listbox using VB and if so how
do I do that.

Then what code do I use to get the command button to know which items the
user selected?

Tom Ogilvy

Multiselect Listbox/ command button
 
If the user is making selections in the listbox, then it must already have a
list


for the commandbutton

With Listbox1
for i = 0 to .Listcount - 1
if .Selected(i) then
msgbox .List(i) & " is selected"
end if
next
End With

--
Regards,
Tom Ogilvy


"C Wilson" wrote:

I have a multiselect listbox where users can select different options that
will eventually be graphed. There's is no code for the list options. I used
the properties boxes for the listbox. I want the user to be able to press a
command button after they've finished their selections to graph what they've
selected. Will I need to create a list for the listbox using VB and if so how
do I do that.

Then what code do I use to get the command button to know which items the
user selected?


C Wilson

Multiselect Listbox/ command button
 
Thanks for the reply, but that's not quite what I was looking for. I want it
to graph their selections. I know I will have to hide the rows I'm just not
sure how to word it to where it will hide all the data except the selections
they made from the box.

"Tom Ogilvy" wrote:

If the user is making selections in the listbox, then it must already have a
list


for the commandbutton

With Listbox1
for i = 0 to .Listcount - 1
if .Selected(i) then
msgbox .List(i) & " is selected"
end if
next
End With

--
Regards,
Tom Ogilvy


"C Wilson" wrote:

I have a multiselect listbox where users can select different options that
will eventually be graphed. There's is no code for the list options. I used
the properties boxes for the listbox. I want the user to be able to press a
command button after they've finished their selections to graph what they've
selected. Will I need to create a list for the listbox using VB and if so how
do I do that.

Then what code do I use to get the command button to know which items the
user selected?



All times are GMT +1. The time now is 05:22 PM.

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