Search in subset of collection

Pieterv

New Member
Joined
Dec 7, 2010
Messages
8
Hi guys,

Does somebody knows if you can search for controls in a userform collection, like in:

/ Dim ctl as Control
/ For Each ctl In UserForm1.Controls
/"do action"


but can exclude one specific subset of the collection of the action ? Like the subset:

/ UserForm1.MultiPage1.Pages(2).Frame21.Controls

For example, is there a conditional statement which i can include like

/ if ctl.location = UserForm1.MultiPage1.Pages(2).Frame21.Controls then
/ "do nothing"

Thanks and kind regards,
Pieter
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Try...

Code:
    Dim Ctrl As Control

    For Each Ctrl In UserForm1.Controls
        If Ctrl.Parent.Name <> "Frame21" Then
            MsgBox Ctrl.Name
        End If
    Next Ctrl

Note, however, controls such as a MultiPage1 and Frame21 will not be excluded. If needed, you can loop through specific controls. For example, if you want to loop through textboxes...

Code:
    Dim Ctrl As Control

    For Each Ctrl In UserForm1.Controls
        If TypeName(Ctrl) = "TextBox" Then
            MsgBox Ctrl.Name
        End If
    Next
 
Upvote 0

Forum statistics

Threads
1,216,073
Messages
6,128,638
Members
449,461
Latest member
kokoanutt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top