Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Populating a listbox with values from a sheet.


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Populating a listbox with values from a sheet.

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Populating a listbox with values from a sheet.

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Populating a listbox with values from a sheet.


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Populating a listbox with values from a sheet.

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Populating a listbox with values from a sheet.


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
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
Populating listbox with sheet names johnb Excel Discussion (Misc queries) 1 May 16th 08 12:33 PM
populating DropDown with Values Of a Column in another Sheet. ZarrinPour Excel Discussion (Misc queries) 7 March 12th 06 02:51 PM
Populating listbox Andy Brown Excel Programming 3 August 16th 04 05:40 PM
Populating a ListBox ToddG Excel Programming 1 June 24th 04 03:18 AM
Saving listbox values to a sheet then repopulate Stuart[_5_] Excel Programming 4 September 15th 03 09:17 PM


All times are GMT +1. The time now is 11:24 AM.

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"