User forms and Combo boxes

Padawan018

Board Regular
Joined
Sep 29, 2006
Messages
63
I have a combo box on a user form and want to populate the combo box with data I have stored on a worksheet. How do I populate the combo box with the data.

e.g.
user form starts on sheet1 and combo box data on sheet2.

Thanks in advance.
 

Some videos you may like

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Welcome to the Board!

Here's one way:

<font face=Tahoma><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> UserForm_Initialize()
    <SPAN style="color:#007F00">'   Add a list from a sheet</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> i <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Integer</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> ws <SPAN style="color:#00007F">As</SPAN> Worksheet
        <SPAN style="color:#00007F">Set</SPAN> ws = Sheets("Sheet2")
        <SPAN style="color:#00007F">For</SPAN> i = 1 <SPAN style="color:#00007F">To</SPAN> 12
            ComboBox1.AddItem ws.Cells(i, 1)
        <SPAN style="color:#00007F">Next</SPAN> i
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

The example loads a list of 12 months from Sheet 2, range A1:A12.

HTH,

Smitty
 

Watch MrExcel Video

Forum statistics

Threads
1,112,937
Messages
5,543,093
Members
410,583
Latest member
gazz57
Top