Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nested If statement to control format of number-type cells TB Excel Worksheet Functions 3 May 16th 08 01:35 AM
Identifying the type of a Worksheet_Change Peter Rooney Excel Programming 6 January 17th 06 02:38 PM
Userform Control Type VBA Dabbler[_2_] Excel Programming 4 June 10th 05 04:01 PM
Identifying a Control Type Chrissy[_4_] Excel Programming 5 July 30th 03 08:25 AM


All times are GMT +1. The time now is 02:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"