Grouping objects in userforms

robertrobert905

Board Regular
Joined
Jun 27, 2008
Messages
139
I would like to group all the objects under the label "1" into one group, and all the objects under label "2" into one group and so on.

This way I can deal with them in 25 groups with ease instead of hundreds of individual objects.

The purple boxes are textboxes and the gray boxes are labels

the only way that I know to group objects is to group ALL the textboxes together is with this code, which Norie showed me.

Code:
For Each ctl In Me.Controls
        If TypeName(ctl) = "TextBox" Then
            ReDim Preserve TextBoxes(1 To I)
            Set TextBoxes(I).TextGroup = ctl
            I = I + 1
        End If
Next ctl

But I need to group them based on the last digit in their name not their type. E.G everything under label one is called P3LB1, P3TXT1_1, P3TXT2_1 etc.

Also once I group them together how do I show or hide them as a group?




dfcbjd.jpg
 

Some videos you may like

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Watch MrExcel Video

Forum statistics

Threads
1,122,223
Messages
5,594,908
Members
413,952
Latest member
JGer

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
Top