Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi everyone, hope you can help me with this one. I'm not very familia with how listboxes work and how to write code for them. My situation i as below: I have a sheet with a bunch of airline names, there may be more than of the same airline in the same column. What I've been able to do s far is make an array and have it hold all the unique airline names. want to then populate the listbox on a form with these airlines so th user can select as many airlines as he wants to do some mor calculations. So basically I'm not sure how to write code for the listbox to make i retrieve the data from the array. Hope I explained it properly. Any suggestions are welcome. Thanks bunch. Coli -- shenlingstyl ----------------------------------------------------------------------- shenlingstyle's Profile: http://www.excelforum.com/member.php...fo&userid=2767 View this thread: http://www.excelforum.com/showthread.php?threadid=48688 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Without seeing any of your code this will have to be kind of generic. It
should look something like this... sub PopulateListBox(byval MyArray() as string) dim intCounter as integer listbox1.clear for intcounter = lbound(MyArray) to ubound(myArray) listbox1.additem myArray(intcounter) next intcounter end sub -- HTH... Jim Thomlinson "shenlingstyle" wrote: Hi everyone, hope you can help me with this one. I'm not very familiar with how listboxes work and how to write code for them. My situation is as below: I have a sheet with a bunch of airline names, there may be more than 1 of the same airline in the same column. What I've been able to do so far is make an array and have it hold all the unique airline names. I want to then populate the listbox on a form with these airlines so the user can select as many airlines as he wants to do some more calculations. So basically I'm not sure how to write code for the listbox to make it retrieve the data from the array. Hope I explained it properly. Any suggestions are welcome. Thanks a bunch. Colin -- shenlingstyle ------------------------------------------------------------------------ shenlingstyle's Profile: http://www.excelforum.com/member.php...o&userid=27672 View this thread: http://www.excelforum.com/showthread...hreadid=486888 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Activeworksheet.Listbox1.List = vArray
-- Regards, Tom Ogilvy "shenlingstyle" wrote in message news:shenlingstyle.1yuw9y_1132592403.3273@excelfor um-nospam.com... Hi everyone, hope you can help me with this one. I'm not very familiar with how listboxes work and how to write code for them. My situation is as below: I have a sheet with a bunch of airline names, there may be more than 1 of the same airline in the same column. What I've been able to do so far is make an array and have it hold all the unique airline names. I want to then populate the listbox on a form with these airlines so the user can select as many airlines as he wants to do some more calculations. So basically I'm not sure how to write code for the listbox to make it retrieve the data from the array. Hope I explained it properly. Any suggestions are welcome. Thanks a bunch. Colin -- shenlingstyle ------------------------------------------------------------------------ shenlingstyle's Profile: http://www.excelforum.com/member.php...o&userid=27672 View this thread: http://www.excelforum.com/showthread...hreadid=486888 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Thanks so much for the help guys, it worked!! I have one further question: How do I determine which items (I enabled multiselect) are selected in the listbox and put these selected items (the names of airilnes) into another array? Thanks again! -- shenlingstyle ------------------------------------------------------------------------ shenlingstyle's Profile: http://www.excelforum.com/member.php...o&userid=27672 View this thread: http://www.excelforum.com/showthread...hreadid=486888 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
dim v as Variant
dim i as long, k as Long Redim v(0 to Listbox1.Listcount-1) k = -1 for i = 0 to Listbox1.Listcount - 1 if listbox1.selected(i) then k = k + 1 v(k) = listbox1.List(i) end if Next Redim Preserve v(0 to k) -- Regards, Tom Ogilvy "shenlingstyle" wrote in message news:shenlingstyle.1yv07m_1132597502.1446@excelfor um-nospam.com... Thanks so much for the help guys, it worked!! I have one further question: How do I determine which items (I enabled multiselect) are selected in the listbox and put these selected items (the names of airilnes) into another array? Thanks again! -- shenlingstyle ------------------------------------------------------------------------ shenlingstyle's Profile: http://www.excelforum.com/member.php...o&userid=27672 View this thread: http://www.excelforum.com/showthread...hreadid=486888 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I actually have a question .. what method did you engage to get the array to hold unique names? Thanx. - Mike "shenlingstyle" wrote: Hi everyone, hope you can help me with this one. I'm not very familiar with how listboxes work and how to write code for them. My situation is as below: I have a sheet with a bunch of airline names, there may be more than 1 of the same airline in the same column. What I've been able to do so far is make an array and have it hold all the unique airline names. I want to then populate the listbox on a form with these airlines so the user can select as many airlines as he wants to do some more calculations. So basically I'm not sure how to write code for the listbox to make it retrieve the data from the array. Hope I explained it properly. Any suggestions are welcome. Thanks a bunch. Colin -- shenlingstyle ------------------------------------------------------------------------ shenlingstyle's Profile: http://www.excelforum.com/member.php...o&userid=27672 View this thread: http://www.excelforum.com/showthread...hreadid=486888 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Populating listbox with sheet names | Excel Discussion (Misc queries) | |||
populating DropDown with Values Of a Column in another Sheet. | Excel Discussion (Misc queries) | |||
Populating listbox | Excel Programming | |||
Populating a ListBox | Excel Programming | |||
Saving listbox values to a sheet then repopulate | Excel Programming |