Grouping textboxes in a userform

dradamowicz

New Member
Joined
Mar 28, 2009
Messages
3
Hello everyone,

I am working on creating a userform to make sure that information gets entered correctly into a spreadsheet. This is a rather large user form with numerous text and list boxes on a number of tabs. I also have a toggle box at the top of the form that helps choose what sort of data I will be needing. When the toggle box is selected I only need about half as much information and do not want users to be able to enter the rest. I am looking to enter code that changes the enabled property of the unneeded boxes to false when the toggle button is selected and back to true when it is clicked off. Unfortunately, this involves about 50 text/list boxes. Things are going to get very messy if I need to write out a seperate line for each of these items.

My question is this. I know there is a way to group these boxes and change the properties of the group as a whole in the editor, but is there a way to refer to such groups and their properties in my code.

Thanks in advance.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi, Welcome to the board!

sounds like you need one or more frames.

You can then do something like this to disable every control in the frame:

Code:
Dim CTL As Control
For Each CTL In Frame1.Controls
    CTL.Enabled = False
Next CTL
 
Upvote 0
If you disable the Frame, then the controls on it should be disabled too.
 
Upvote 0
One way would be to resize the userform so that the .Top's of the unneeded textboxes were larger than the UF's Height.

Another approach would be to put a frame around those controls and set the frame's Enabled to False.
 
Upvote 0
Hi rory,

True, but I like to disable each control as well, as otherwise it's not obvious that the control(s) are unavailable.

Generally I would agree, but I got the impression they would be empty - in which case it's pretty much the same either way!
 
Upvote 0
Wow, thank you everyone for the quick replies. I hadn't thought of using frames. That would at least solve the bulk of my problem. But it is a point that I would like to visually indicate that these boxes are no longer active (possibly changing their background color). If there's not really a way to do this as a group I'll use the frames and be happy, but it would be great if there was another way.
 
Upvote 0

Forum statistics

Threads
1,213,526
Messages
6,114,136
Members
448,551
Latest member
Sienna de Souza

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