Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default MyArray (ComboBox.ListCount-1) possible?

"How do I set the total number of elements of an array to match the total
number of items in a ComboBox

thanks in advance"

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default MyArray (ComboBox.ListCount-1) possible?

"How do I set the total number of elements of an array to match
the total number of items in a ComboBox


Give this a try (where I assumed the ComboBox was named ComboBox1)...

Dim X As Long
Dim MyArray() As String
ReDim MyArray(0 To ComboBox1.ListCount - 1)
For X = 0 To ComboBox1.ListCount - 1
MyArray(X) = ComboBox1.List(X)
Next

Rick
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default MyArray (ComboBox.ListCount-1) possible?

Hi,

You can put the entire combox into an variant array in one shot:
-------------------------------------------------------------------------
Private Sub UserForm_Click()
Dim i As Long
Dim v ''' array

''' put the entire listbox into an array
v = Combobox1.List

''' display first column (index 0)
For i = LBound(v, 1) To UBound(v, 1)
MsgBox v(i, 0)
Next
End Sub

or you can create it yourself:
--------------------------------
Private Sub UserForm_Click()
dim v() as string

''' size the array
redim v ( 0 To Combobox1.Listcount-1)

''' fill the array
for i = 0 to Combobox1.Listcount-1
v(i)=Combobox1.List(i)
next

''' Display the array
For i = LBound(v) To UBound(v)
MsgBox v(i)
Next
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"LuisE" wrote:

"How do I set the total number of elements of an array to match the total
number of items in a ComboBox

thanks in advance"

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
XL 2003: ListBox ListCount (and other) properties missing from Local Variables window Michel S. Excel Programming 3 February 14th 07 07:35 PM
Dim MyArray() as Long, Dim MyArray() as String, etc. quartz[_2_] Excel Programming 4 April 28th 05 04:32 PM
Dim MyArray vs. Dim MyArray() Alan Beban[_2_] Excel Programming 12 November 14th 04 06:13 PM
Can I reset an array to myarray() Alan Beban[_4_] Excel Programming 1 February 20th 04 06:16 PM
Redim MyArray Peter Pantus Excel Programming 2 September 27th 03 03:37 PM


All times are GMT +1. The time now is 04:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"