ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Populating data in ComboBoxes on UserForms (https://www.excelbanter.com/excel-programming/395464-populating-data-comboboxes-userforms.html)

[email protected]

Populating data in ComboBoxes on UserForms
 
Hi

I am trying to create a User from that has a drop-down for the user to
select from a pre-defined list.

I have created a combobox on the user form and have no idea how to
populate my list into this when the form opens for the user.

Is there is something really basic I am missing here? I have tried
playing around with ComboBox.AddItem "xxx" for example.
The combo box is still blank when I open the user form:(

Martin


John Bundy

Populating data in ComboBoxes on UserForms
 
You've got it but I think your timing is off. Where are you adding items.
Typically you activate the userform with userform1.show somewhere like in the
workbook open event, well before you show it, add all of your items.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


" wrote:

Hi

I am trying to create a User from that has a drop-down for the user to
select from a pre-defined list.

I have created a combobox on the user form and have no idea how to
populate my list into this when the form opens for the user.

Is there is something really basic I am missing here? I have tried
playing around with ComboBox.AddItem "xxx" for example.
The combo box is still blank when I open the user form:(

Martin



[email protected]

Populating data in ComboBoxes on UserForms
 

Excellent, thanks dude :)


On 14 Aug, 19:38, John Bundy (remove) wrote:
You've got it but I think your timing is off. Where are you adding items.
Typically you activate the userform with userform1.show somewhere like in the
workbook open event, well before you show it, add all of your items.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.

" wrote:
Hi


I am trying to create a User from that has a drop-down for the user to
select from a pre-defined list.


I have created a combobox on the user form and have no idea how to
populate my list into this when the form opens for the user.


Is there is something really basic I am missing here? I have tried
playing around with ComboBox.AddItem "xxx" for example.
The combo box is still blank when I open the user form:(


Martin




JLGWhiz

Populating data in ComboBoxes on UserForms
 
There are two ways to populate the combobox. If it is a single column and
your data source is located in a single row or single column on the
worksheet, you can use the row source in the combobox properties by entering
the cell range reference, exmp: a10:a20.

If you want to use the AddItem method. Put it in the UserForm_Initialize
code module. When you then execute the command UserForm1.Show, the
Initialize code executes first and loads the combo box.

"John Bundy" wrote:

You've got it but I think your timing is off. Where are you adding items.
Typically you activate the userform with userform1.show somewhere like in the
workbook open event, well before you show it, add all of your items.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


" wrote:

Hi

I am trying to create a User from that has a drop-down for the user to
select from a pre-defined list.

I have created a combobox on the user form and have no idea how to
populate my list into this when the form opens for the user.

Is there is something really basic I am missing here? I have tried
playing around with ComboBox.AddItem "xxx" for example.
The combo box is still blank when I open the user form:(

Martin




All times are GMT +1. The time now is 07:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com