Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How do I pass an array to a listbox?

I have a variant array "class" which I wish to pass to a list box on
another form.

Please advise.

--
Apachie,
Photoshop,
Flash
Dreamweaver
MySql
PHP
Training videos : www.wz2k.co.uk
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How do I pass an array to a listbox?

Could you perhaps provide a few more details about exactly what
you are trying to do?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Titus A Ducksass - AKA broken-record" wrote
in message ...
I have a variant array "class" which I wish to pass to a list
box on
another form.

Please advise.

--
Apachie,
Photoshop,
Flash
Dreamweaver
MySql
PHP
Training videos : www.wz2k.co.uk



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default How do I pass an array to a listbox?

I assume that yu have a list of names that you want to transfer to a listbox.
Assuming that your list box is on a UserForm the following will work:

Private Sub UserForm_Initialize()
' Declare the array (for three names)
Dim MyArray(3) As String
Dim r As Integer
' Fill the array
MyArray(1) = "Colin"
MyArray(2) = "Bill"
MyArray(3) = "Fred"
' Loop through the array names
' and spit into the list box
For r = 1 To UBound(MyArray, 1)
' Assumes that the list box
' name is ListBox1
ListBox1.AddItem MyArray(r)
Next r
End Sub

Regards,

Alasdair Stirling

"Titus A Ducksass - AKA broken-record" wrote:

I have a variant array "class" which I wish to pass to a list box on
another form.

Please advise.

--
Apachie,
Photoshop,
Flash
Dreamweaver
MySql
PHP
Training videos : www.wz2k.co.uk

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How do I pass an array to a listbox?

On Tue, 22 Mar 2005 15:13:22 -0600, "Chip Pearson"
wrote:

Could you perhaps provide a few more details about exactly what
you are trying to do?


I am trying to read in a worksheet into the variant array which then
should be made available from a list box
I can reference every element of the array but cannot figure out how
to pass it to the list box. In C I would pass the address of the
array but in excel, I cannot figure it out.

Sample data in the sheet is:'

Class Date Time
Dogs 08/04/2005 15:00
Dogs 09/04/2005 19:00
Dogs 09/04/2005 15:00
Cats & Dogs 10/04/2005 15:00
Cats & Dogs 16/04/2005 19:00
Cats & Dogs 16/04/2005 15:00
Cats 27/03/2005 15:00
Cats 27/03/2005 19:00

There are c.136 records and I expect it to change by 20 up and down
but will remain roughly 136 which is why I am using the variant array
as the exact number will not be known at runtime.


--
Apachie,
Photoshop,
Flash
Dreamweaver
MySql
PHP
Training videos : www.wz2k.co.uk
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How do I pass an array to a listbox?

On Tue, 22 Mar 2005 15:31:05 -0800, "Alasdair Stirling"
wrote:

I assume that yu have a list of names that you want to transfer to a listbox.
Assuming that your list box is on a UserForm the following will work:

Private Sub UserForm_Initialize()
' Declare the array (for three names)
Dim MyArray(3) As String
Dim r As Integer
' Fill the array
MyArray(1) = "Colin"
MyArray(2) = "Bill"
MyArray(3) = "Fred"
' Loop through the array names
' and spit into the list box
For r = 1 To UBound(MyArray, 1)
' Assumes that the list box
' name is ListBox1
ListBox1.AddItem MyArray(r)
Next r
End Sub

Regards,
Alasdair Stirling


Thanks, I will look at that - there are too many records to
permanently store in the array so I will load and save them in the
sheet as appropriate.
Thanks again.
Derek

--
Apachie,
Photoshop,
Flash
Dreamweaver
MySql
PHP
Training videos : www.wz2k.co.uk
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
combining cells and array from different sheets into an array to pass to IRR() [email protected] Excel Discussion (Misc queries) 3 September 11th 06 07:17 AM
Pass an array to Rank Biff Excel Worksheet Functions 12 June 29th 05 04:15 PM
How can I pass an array as TextToDisplay to a hyperlink? Jay Fincannon Excel Programming 4 January 28th 05 01:45 AM
Pass array of worksheets to ActiveX DLL (VB6) Hank Scorpio Excel Programming 25 June 21st 04 10:53 AM
How to pass ListBox into a Sub? RADO[_3_] Excel Programming 2 November 16th 03 08:22 PM


All times are GMT +1. The time now is 04:41 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"