Thread: VBA Combo Box
View Single Post
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

Is this on a userform?

If yes, then maybe it should be in the Userform_initialize procedure?

If it's on a worksheet, maybe in the auto_open or workbook_open procedures.

Jeff wrote:

I have a combo box that I want to populate with a list of names.

I do not want to reference names in the worksheet - using "RowSource" - I
want to write the names in the code.

I tried the following code:

Private Sub ComboBox1_Change()
With ComboBox1
.RowSource = ""
.AddItem "Male"
.AddItem = "Female"
End With
End Sub

This gives me an error. Does anyone know where the code should be added.


--

Dave Peterson