VBA & Macro Problems

Hide Form Control Group Box Borders in Excel with VBA

John WilsonJohn Wilson Nov 18, 2026 868 views

Question details

Hide the borders of Excel Form Control group boxes that interfere with data entry.

Hide Form Control Group Box Borders in Excel with VBA
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet contains several Form Control group boxes, and the user wants their outlines out of the way during data entry.
Observed behavior
Setting ActiveSheet.GroupBoxes.Visible to False in the VBA Immediate window does not hide the group boxes.
Before you start

Open the workbook in desktop Excel and select the worksheet containing the Form Control group boxes. Enable macros only if you trust the workbook, and save it as an Excel Macro-Enabled Workbook (.xlsm) if you want to keep the macro.

Solution 1Recommended

Hide Form Control group boxes with a VBA macro

Use this macro to hide group box shapes on the active worksheet while leaving other shape types unchanged.

This method hides each entire group box, including its border and caption; it does not make only the border invisible. It targets Form Control group boxes, not ActiveX controls or ordinary shapes.

1
Open the VBA editor

In desktop Excel, select the worksheet you want to change, then choose Developer > Visual Basic. If the Developer tab is hidden, enable it through Excel's ribbon customization settings.

2
Add a standard module

In the VBA editor, select the workbook in the Project Explorer, then choose Insert > Module.

3
Enter the macro

Paste this code into the module: Sub HideGroupBoxes() Dim shp As Shape For Each shp In ActiveSheet.Shapes If shp.Type = msoFormControl Then If shp.FormControlType = xlGroupBox Then shp.Visible = False End If End If Next shp End Sub

4
Run the macro

Return to Excel and confirm that the intended worksheet is active. Choose Developer > Macros, select HideGroupBoxes, and click Run.

Hide Form Control group boxes with a VBA macro
Show the group boxes again: In the VBA editor, change shp.Visible = False to shp.Visible = True, then run the macro again on the same worksheet.
Free Microsoft Office alternative

Work with Excel spreadsheets in WPS Office

WPS Office is a free, lightweight alternative for working with spreadsheets in a familiar interface. Open compatible Excel files to make everyday edits and move between office suites more easily; it does not fix Excel's VBA behavior.

Open and edit Excel spreadsheet formats such as XLSXUse a familiar spreadsheet interface for everyday worksheet tasksWork with worksheet data in a lightweight office suiteMove compatible documents between WPS Office and Microsoft Office
microsoft office alternative - wps office

Frequently Asked Questions

Does the macro hide only the group box border?

No. Setting the group box shape's Visible property to False hides the entire group box, including its border and caption.

Will the macro hide group boxes on every worksheet?

No. It loops through ActiveSheet.Shapes, so select the worksheet you want to change before running it from Developer > Macros.

How can I make the group boxes visible again?

Open Developer > Visual Basic, change shp.Visible = False to shp.Visible = True in the macro, and run it again on the affected worksheet.

Why does the macro check the shape type first?

It checks shp.Type = msoFormControl before reading FormControlType, so the group box check is applied only to Form Controls rather than other worksheet shapes.

What file type should I use to keep the macro?

Choose File > Save As and select Excel Macro-Enabled Workbook (.xlsm). The .xlsx format cannot retain VBA macros.