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.
 
Hi,

Try something like this:
Code:
Private Sub CheckBox1_Click()
Dim CTL As Control

Frame1.Enabled = CheckBox1.Value
For Each CTL In Frame1.Controls
    If TypeName(CTL) = "TextBox" _
    Or TypeName(CTL) = "ComboBox" Then
        If CheckBox1.Value = False Then
            CTL.BackColor = vbButtonFace
        Else
            CTL.BackColor = vbWhite
        End If
    End If
Next CTL
End Sub
 
Upvote 0

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Thanks again to everyone.

Mikerickson, I tried the visible idea, but that left a rather large (and ugly) blank spot on the form. It acomplishes everything I was looking to do except for the aestetics.

Al b cnu, that is exactly what I was looking to do. Grouping controls by putting them in a frame is something I never would have thought to do.

Wow, this board is great.
 
Upvote 0
You could also use a multipage control and put all the secondary controls onto a different page.
 
Upvote 0

Forum statistics

Threads
1,215,148
Messages
6,123,301
Members
449,095
Latest member
Chestertim

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