Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How can I enumerate form items so that I can, say, change BackColor,
checkbox status, etc. in a loop? or, as an alternative, if I generate the object name ("form1.cb1", "form1.cb2", etc) as a string, how can I refer to it using the string? Thanks, ....kurt |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Dim ctl As Control For Each ctl In Me.Controls Select Case TypeName(ctl) Case "CheckBox": MsgBox "checkbox " & ctl.Name Case "CommandButton": MsgBox "Button " & ctl.Name End Select Next ctl -- HTH Bob Phillips "Kurt" wrote in message ... How can I enumerate form items so that I can, say, change BackColor, checkbox status, etc. in a loop? or, as an alternative, if I generate the object name ("form1.cb1", "form1.cb2", etc) as a string, how can I refer to it using the string? Thanks, ...kurt |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
for i = 1 to 2
set cbx = form1.controls("cb" & i) Next or sStr = "cb1" set cbx = form1.Controls(sStr) -- Regards, Tom Ogilvy "Kurt" wrote in message ... How can I enumerate form items so that I can, say, change BackColor, checkbox status, etc. in a loop? or, as an alternative, if I generate the object name ("form1.cb1", "form1.cb2", etc) as a string, how can I refer to it using the string? Thanks, ...kurt |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is this a userform, or a worksheet? I have written routines which loop
through control objects on userforms as follows: Dim ctrl as Control For Each ctrl In Me.Controls If ctrl.Tag = "SpecialItem" Then 'Do things to all items I have set the Tag property a certain way for (i.e., = 'SpecialItem' or whatever) End if 'OR If LCASE(left(ctrl.Name,3)) = "ckb" then 'Do things to items I have named with prefix 'ckb' End If 'OR If TypeName(ctrl) = "CheckBox" then 'Do things to all checkboxes End if Next ctrl Note: The second item - testing the name - does not work if you created the control dynamically as a control array, such as Dim chk(1 to 3) As Control Set chk(1) = Controls.Add("Forms.CheckBox.1", True) Set chk(2) = Controls.Add("Forms.CheckBox.1", True) Set chk(3) = Controls.Add("Forms.CheckBox.1", True) because the name property for each will just be "-1" "Kurt" wrote in message ... How can I enumerate form items so that I can, say, change BackColor, checkbox status, etc. in a loop? or, as an alternative, if I generate the object name ("form1.cb1", "form1.cb2", etc) as a string, how can I refer to it using the string? Thanks, ...kurt |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks to all who replied. This is exactly what I was looking for. [:-)]
....kurt "Kurt" wrote in message ... How can I enumerate form items so that I can, say, change BackColor, checkbox status, etc. in a loop? or, as an alternative, if I generate the object name ("form1.cb1", "form1.cb2", etc) as a string, how can I refer to it using the string? Thanks, ...kurt |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
order form with multiple items and sizes for items | Excel Discussion (Misc queries) | |||
enumerate sheet | Excel Worksheet Functions | |||
how to enumerate? | New Users to Excel | |||
2nd Form deselects list box items on main form | Excel Programming | |||
Is there any way to enumerate the cell which contain a formula? | Excel Programming |