![]() |
Identifying Control type
Hi,
When looping through all the controls collection on a form is there a property that can be examined to determine what type of control each control is? Graham |
Identifying Control type
Graham,
Two approaches. Regards, Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware Sub FindOutWhatKind() Dim Ctrl As MSForms.Control For Each Ctrl In UserForm1.Controls MsgBox TypeName(Ctrl) Next Set Ctrl = Nothing End Sub Sub FindOutWhatKind2() Dim Ctrl As MSForms.Control For Each Ctrl In UserForm1.Controls If TypeOf Ctrl Is MSForms.CheckBox Then MsgBox Ctrl.Name ElseIf TypeOf Ctrl Is MSForms.CommandButton Then MsgBox Ctrl.Name 'more ElseIf End If Next Set Ctrl = Nothing End Sub '---------- "Graham Payne" wrote in message ... Hi, When looping through all the controls collection on a form is there a property that can be examined to determine what type of control each control is? Graham |
Identifying Control type
Jim,
thanks for that it works atreat. Regards, Graham "Jim Cone" wrote in message ... Graham, Two approaches. Regards, Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware Sub FindOutWhatKind() Dim Ctrl As MSForms.Control For Each Ctrl In UserForm1.Controls MsgBox TypeName(Ctrl) Next Set Ctrl = Nothing End Sub Sub FindOutWhatKind2() Dim Ctrl As MSForms.Control For Each Ctrl In UserForm1.Controls If TypeOf Ctrl Is MSForms.CheckBox Then MsgBox Ctrl.Name ElseIf TypeOf Ctrl Is MSForms.CommandButton Then MsgBox Ctrl.Name 'more ElseIf End If Next Set Ctrl = Nothing End Sub '---------- "Graham Payne" wrote in message ... Hi, When looping through all the controls collection on a form is there a property that can be examined to determine what type of control each control is? Graham |
All times are GMT +1. The time now is 09:46 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com