![]() |
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" |
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 |
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" |
All times are GMT +1. The time now is 02:03 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com