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
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
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.