Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel - Detect type of object on UserForm

Status
Not open for further replies.

oneshadow

IS-IT--Management
Dec 23, 2004
125
ID
I have 2 textboxes and 1 combo on a form and I would like to loop for every object on form. If it is a textbox then I will do something.

In VB it will be like:

Dim obj As Object
For Each obj in Form1
If TypeOf obj Is TextBox Then

'...
End If
Next


In VBA, TypeOf method returns the object name.

Q: How can I detect object type?
Thanks in advance
 
This works for me

Dim oControl As Control

For Each oControl In Me.Controls
If TypeOf oControl Is TextBox Then
Debug.Print oControl.Name
End If
Next oControl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top