ComboBox.List

  • Thread starter Thread starter Gordon
  • Start date Start date
G

Gordon

Trying to load ComboBox from Dynamic Array
Code: Declaration: Option Base 1, Public MyArray()
Procedure: N = 1
ReDim MyArray(N)
MyArray(N) = ActiveCell (and so on)

ReplaceName.Show (UserForm)
Initialize: Me.NameComboBox.List =
MyArray()
(also tried MyArray)

Error: NameComboBox.List...(NameComboBox.List = Null)
Dave Peterson suggested the above, but it doesn't work.

Thank you,
GJ
 
This worked fine for me:

In a general module:
Option Explicit
Public myArray() As String
Sub testme()
Dim iCtr As Long
ReDim myArray(1 To 10)
For iCtr = 1 To 10
myArray(iCtr) = ActiveSheet.Cells(iCtr, "A").Value
Next iCtr
UserForm1.Show
End Sub


Behind the userform:
Option Explicit
Private Sub UserForm_Initialize()
Me.ComboBox1.List = myArray
End Sub

If the equivalent doesn't work for you, you may want to post more details--like
the actual code that fails.
 
Back
Top