Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform Control Type
I'm trying to step through a collection of controls on a userform and, based
on type, take certain steps. Does anyone know the syntax for determining a userform control's 'type'? For example: is Control(i) a Textbox, Checkbox, Combobox, etc. Thanks, VBA Dabbler |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform Control Type
if you have vba6 (xl2000+)
dim ctl as object for each ctl in me.controls use TypeOf ctl IS msforms.Combobox etc. intellisense will guide you... when you type in msforms. but you can leave it out afterwards.. next if you need to code for xl97 use lcase(TypeName(ctl)) = "combobox" etc. the names for the classes can be found in the object browser in the msforms library. -- keepITcool | www.XLsupport.com | keepITcool chello nl | amsterdam VBA Dabbler wrote : I'm trying to step through a collection of controls on a userform and, based on type, take certain steps. Does anyone know the syntax for determining a userform control's 'type'? For example: is Control(i) a Textbox, Checkbox, Combobox, etc. Thanks, VBA Dabbler |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform Control Type
Use the TypeOf operator to determine the type of control. E.g.,
Dim Ctrl As MSForms.Control For Each Ctrl In UserForm1.Controls If TypeOf Ctrl Is MSForms.CheckBox Then ' do something for checkbox ElseIf TypeOf Ctrl Is MSForms.ComboBox Then ' do something for combobox ElseIf TypeOf Ctrl Is MSForms.CommandButton Then ' do something for commandbutton '... End If Next Ctrl -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "VBA Dabbler" wrote in message ... I'm trying to step through a collection of controls on a userform and, based on type, take certain steps. Does anyone know the syntax for determining a userform control's 'type'? For example: is Control(i) a Textbox, Checkbox, Combobox, etc. Thanks, VBA Dabbler |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform Control Type
Great! Thanks for the suggestions, both work like a charm.
"keepITcool" wrote: if you have vba6 (xl2000+) dim ctl as object for each ctl in me.controls use TypeOf ctl IS msforms.Combobox etc. intellisense will guide you... when you type in msforms. but you can leave it out afterwards.. next if you need to code for xl97 use lcase(TypeName(ctl)) = "combobox" etc. the names for the classes can be found in the object browser in the msforms library. -- keepITcool | www.XLsupport.com | keepITcool chello nl | amsterdam VBA Dabbler wrote : I'm trying to step through a collection of controls on a userform and, based on type, take certain steps. Does anyone know the syntax for determining a userform control's 'type'? For example: is Control(i) a Textbox, Checkbox, Combobox, etc. Thanks, VBA Dabbler |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform Control Type
Chip,
Thanks for your suggestions. I've used your example below and it work well. Regards, VBA Dabbler "Chip Pearson" wrote: Use the TypeOf operator to determine the type of control. E.g., Dim Ctrl As MSForms.Control For Each Ctrl In UserForm1.Controls If TypeOf Ctrl Is MSForms.CheckBox Then ' do something for checkbox ElseIf TypeOf Ctrl Is MSForms.ComboBox Then ' do something for combobox ElseIf TypeOf Ctrl Is MSForms.CommandButton Then ' do something for commandbutton '... End If Next Ctrl -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "VBA Dabbler" wrote in message ... I'm trying to step through a collection of controls on a userform and, based on type, take certain steps. Does anyone know the syntax for determining a userform control's 'type'? For example: is Control(i) a Textbox, Checkbox, Combobox, etc. Thanks, VBA Dabbler |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Control Sequence from Userform Control | Excel Programming | |||
Type of textbox on userform | Excel Programming | |||
Identifying a Control Type | Excel Programming | |||
UserForm Control | Excel Programming | |||
UserForm Control | Excel Programming |