Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
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. |
#2
![]() |
|||
|
|||
![]()
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 |
#3
![]() |
|||
|
|||
![]() "Dave Peterson" wrote: It is in a form Private Sub UserForm_Initialize() With ComboBox1 ..RowSource = "" ..AddItem "Male" ..AddItem = "Female" End With End Sub Gives an error. Is this what you meant by "Userform_Initialize" procedure |
#4
![]() |
|||
|
|||
![]()
Yep.
And I didn't notice your typo in the original post: .AddItem = "Female" should be: .AddItem "Female" (no equal sign) Jeff wrote: "Dave Peterson" wrote: It is in a form Private Sub UserForm_Initialize() With ComboBox1 .RowSource = "" .AddItem "Male" .AddItem = "Female" End With End Sub Gives an error. Is this what you meant by "Userform_Initialize" procedure -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Nesting Combo Boxes /Returning an Array | Excel Discussion (Misc queries) | |||
Dynamic Combo Box | Excel Worksheet Functions | |||
connecting combo boxes to yield data in another cell. | Excel Discussion (Misc queries) | |||
"Combo Box - getting control combo box to stick in place in worksh | Excel Discussion (Misc queries) | |||
dynamic combo boxes | Excel Worksheet Functions |