Dynamic Userform

Paul van de Laar

New Member
Joined
May 26, 2011
Messages
1
Hello All,
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
I have a userform with 22 labels and 22 comboboxen and 22 textboxen.<o:p></o:p>
Start with label1 till label22 <o:p></o:p>
Next to the label are 1 combobox and 1 textbox they cover each other. Also 1 till 22<o:p></o:p>
<o:p> </o:p>
The data for the labels captions are in my sheet on one row and 22 kolomn’s<o:p></o:p>
<o:p> </o:p>
If in the kolom in the rows below the row with the label captions is filled with text then <o:p></o:p>
the combobox is visible=true and the textbox visible =false<o:p></o:p>
If the rows below the row with the lable caption are empty then the textbox visible = true and the combobox visible=false<o:p></o:p>
<o:p> </o:p>
I want to fill the labels and the combobox with a for next loop<o:p></o:p>
Something like this<o:p></o:p>
<o:p> </o:p>
For x = 1 to 22<o:p></o:p>
<o:p> </o:p>
Userform1.Label & x = cells(1,x)<o:p></o:p>
If cells(2,x)>”” then <o:p></o:p>
Userform1.ComboBox & x.visible=true<o:p></o:p>
Userform1.TextBox & x.visible=false<o:p></o:p>
Userform1.combobox & x.RowSource=address van range cells(2,x) till cells(25,x)<o:p></o:p>
else<o:p></o:p>
Userform1.textbox & x.visible=true<o:p></o:p>
Userform1.ComboBox & x.visible=False<o:p></o:p>
<o:p> </o:p>
Next x<o:p></o:p>
<o:p> </o:p>
this peace off code will never work like this.<o:p></o:p>
<o:p> </o:p>
Question:<o:p></o:p>
Is it possible to use Label & x to fill Label1 till Label22<o:p></o:p>
Is it possible to use ComboBox & x to fill the rowsource<o:p></o:p>


Thanks

Paul
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
I want same thing but with multipage control.
I am searching this forum for this otherwise i'll give it a try myself.
 
Upvote 0
Something like this? Note: I have not tested this as I didn't want to create a form with all of those controls. As long as the names of the controls match, it should work. Also not sure about the RowSource range.

Code:
For x = 1 To 22
    UserForm1.Controls("Label" & x) = Cells(1, x)
    If Cells(2, x) > ”” Then
        UserForm1.Controls("ComboBox" & x).Visible = True
        UserForm1.Controls("TextBox" & x).Visible = False
        UserForm1.Controls("ComboBox" & x).RowSource = Range(Cells(2, x) & ":" & Cells(25, x))
    Else
        UserForm1.Controls("Textbox" & x).Visible = True
        UserForm1.Controls("ComboBox" & x).Visible = False
    End If
Next x
 
Upvote 0

Forum statistics

Threads
1,224,506
Messages
6,179,159
Members
452,892
Latest member
yadavagiri

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