Combobox at run time .add from range and use scripting dictionary

dizzydunham

New Member
Joined
Mar 22, 2014
Messages
30
Hi,

I have created a userform which populates with comboboxes at run time.

How do I populate them from a range. and use scripting.dictionary

I have done this before with a combobox at design, how do I structure the code referring to dynamic controls (SName & i)?

HTML:
    With CreateObject("scripting.dictionary")
        For Each Cl In Sheets("Applicants").ListObjects("Table7").ListColumns(3).DataBodyRange
            If Not .exists(Cl.Value) Then .Add Cl.Value, Nothing
        Next Cl
         UserForm4.SName& i.Clear
         UserForm4.SName&i.List = Application.Transpose(.keys)
         .RemoveAll
    End With

Many thanks for looking.
 
Last edited:

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.
How/when are you creating the comboboxes?
 
Upvote 0
How/when are you creating the comboboxes?

When the user inputs a number in the main userform, it opens up another userform and populates it with the required comboboxes then. there is a command button also which sends values to a listbox for viewing ,sheets, hides the userform etc.

ive only got my head around the loop method for this to happen just recently. So i'm finding this a little more challenging than normal.

Code:
With Controls.Add("Forms.Combobox.1", Name:="FName" & i)
.Top = 50 * (i - 1) + 40
.Left = 70
.Width = 90
.Height = 20
.TabIndex = i * 2 - 1
End With
 
Last edited:
Upvote 0
Hi,

Try this :

Code:
UserForm4.Controls([COLOR=#333333]"FName" & i).Clear
[/COLOR]UserForm4.Controls([COLOR=#333333]"FName" & i)[/COLOR][COLOR=#333333].List = Application.Transpose(.keys)[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,620
Latest member
dsubash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top