create dynamic comboboxes

M

Martin

Hello,

is it possible to create dynamic combo boxes?

I have an userform which saves the file into a specified folder. The user
can choose one out of 4 predefined folders from a combobox. I want to add a
button "Add folder", by what the user can enter the path and the folder would
appear in the comobbox.

The users are not proficient to fill the combobox via VBA and I want them to
be able to add folders without proggramming.

thank you

Martin
 
J

JLGWhiz

If the combobox is populated using RowSource, then the code behind the
command button would have to resize the row source range and add the new
folder to the rowsource range.

If the combobox is populated during the initialize event using the add item
method, then the command button code can use the add item method to add the
new folder to the combo box list as below.

Private Sub CommandButton1_Click()
ComboBox1.AddItem Selection
End Sub

This assumes the user will have typed a new folder name into a cell and
then selects that cell.
 
P

Patrick Molloy

if you have a text box above the listbox, and a button next to at , your
user can tyep the address in the textbox then click the button
the button's click event should be

listbox1.AddItem Textbox1.text
' these next two are optional
textbox1.text=""
listbox1.listindex = listbox1.listcount-1
'
this clears the textbox and highlights the last row of the listbox. this
though is akin to clicking the list box ...so don't use this if you're
trapping the listbox click event
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top