Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Assigning the name of a userform/control to a changing string
I want to attach a name to a userform (i.e. userform1,2,3 etc) or a control
within a form (i.e. TextBox1,2,3 etc) by means of a loop. How do I name the userform/control with a variable such as a string ... Dim UF as UserForm Dim str as string Dim j as Integer For j = 1 to 5 str = ³UserForm² & j UF.Name = str UF.Show Next j - It doesn¹t work, but is it close? Thanks for any help. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Assigning the name of a userform/control to a changing string
Hi Brad
What you want can only be accomplished, if the userform/control is created at run time. It's not possible to alter a name given at design time programmically. This example shows the basics: Private Sub UserForm_Initialize() Dim Counter As Long For Counter = 1 To 3 Me.Controls.Add "forms.checkbox.1", Name:="Burger" & Counter Next Counter Me.Controls("Burger2").Value = True ' or Me!burger2.Value = True MsgBox Me!burger2.Value End Sub -- Best Regards Leo Heuser MVP Excel Followup to newsgroup only, please. "Brad Patterson" skrev i en meddelelse ... I want to attach a name to a userform (i.e. userform1,2,3 etc) or a control within a form (i.e. TextBox1,2,3 etc) by means of a loop. How do I name the userform/control with a variable such as a string ... Dim UF as UserForm Dim str as string Dim j as Integer For j = 1 to 5 str = "UserForm" & j UF.Name = str UF.Show Next j - It doesn't work, but is it close? Thanks for any help. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Assigning the name of a userform/control to a changing string
Thanks leo, but I wanted to name the item iteratively * when they already
exist. It¹s just trying to refer to the textbox with a string that had me stumped, but I know the answer thanks to your post and the Me.Control(²textbox ....²).value command. Thanks! in article , Leo Heuser at wrote on 16/7/03 6:37 PM: Private Sub UserForm_Initialize() Dim Counter As Long For Counter = 1 To 3 Me.Controls.Add "forms.checkbox.1", Name:="Burger" & Counter Next Counter Me.Controls("Burger2").Value = True ' or Me!burger2.Value = True MsgBox Me!burger2.Value End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Finding a single word match in a text string and assigning a code | Excel Worksheet Functions | |||
Enter date in userform using Calendar Control | Excel Discussion (Misc queries) | |||
Passing variable values to userform control | Excel Discussion (Misc queries) | |||
control toolbox and userform toolbars in XL 03 | Excel Discussion (Misc queries) | |||
Combo Box Control keeps changing sizes | Excel Worksheet Functions |