Reputation: 23187
I want some default values in my combo boxes but can't seem to figure out how to do this without writing a module that populates the combo boxes. How can I manually fill in the combo boxes so I don't have to use code to do something so simple.
Thanks
Upvotes: 2
Views: 19462
Reputation: 1
You could also try something like
Private Sub worksheet_Activate()
With Sheet1.ComboBox1 .List = Range("a1:a20").Value End With 'This will give a list of the values from Cell A1 to Cell A20 End Sub
Upvotes: 0
Reputation: 57919
What program are you using? Where is the combobox. For example, in Excel, you can have a combobox on a form or on the worksheet, and the answer is going to depend on these factors.
In Excel, you can define your default values in a worksheet (which you can hide, if you want), and set the combo box source to the corresponding range -- no code required.
Please elaborate on your requirements and you'll get more specific answers.
Upvotes: 2
Reputation: 25252
I guess you speak about Access ? If that's the case,
Upvotes: 2
Reputation: 55009
If I understand you question correctly, I'm fairly sure you have to have code somewhere, I don't think VBA supports as I seem to remember that VB6 did to just add the items in a property, but you don't have to create a separate module, just something like this should work:
Private Sub UserForm_Activate()
ComboBox1.AddItem "Text1"
ComboBox1.AddItem "Text2"
ComboBox1.AddItem "Text3"
End Sub
Upvotes: 0