option groups, formatting

D

dave

I have 10 option groups on a form but want to make the
group outlines invisible. Is there a way to do this?

The option groups were placed using the Form menu.
 
C

Charles Maxson

Dave,

You can hide group boxes and have the individual groups still operate as
expected. Assuming a naming convention where all of your group boxes have a
name beginning with "grp", the following code will toggle the view of those
groups from visible to hidden:

Sub toggleGroupsHidden()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
If Left(shp.Name, 3) = "grp" Then
shp.Visible = Not shp.Visible
End If
Next
End Sub


Charles
www.officezealot.com
 
D

Dave Peterson

You can get them all visible/hidden with:

Option Explicit
Sub test01()
ActiveSheet.GroupBoxes.Visible = False
End Sub

Or you could cycle through all the groupboxes:
Sub test02()
Dim GBox As GroupBox
For Each GBox In ActiveSheet.GroupBoxes
GBox.Visible = False
Next GBox
End Sub

Or you could go through the shapes collection
Sub test03()
Dim myShape As Shape
For Each myShape In ActiveSheet.Shapes
If myShape.Type = msoFormControl Then
If myShape.FormControlType = xlGroupBox Then
myShape.Visible = False
End If
End If
Next myShape
End Sub

And if you had some you want visible and some hidden, you could use their names:

ActiveSheet.GroupBoxes("group box 1").Visible = False
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top