Office Settings & Configuration

How to Expand or Collapse Row Groups on a Protected Excel Worksheet

Huda QurayshiHuda Qurayshi Nov 3, 2026 868 views

Question details

The user needs to be able to expand or collapse outline row or column groups while an Excel worksheet is password-protected.

How to Expand or Collapse Row Groups in a Protected Excel Worksheet
Product
Excel
Device & OS
not provided
Scenario
The user has grouped rows or columns to organize data in an Excel worksheet and then protected the sheet to prevent unauthorized editing or formatting changes.
Observed behavior
After protecting the worksheet, the '+' and '-' outline buttons become unresponsive or unavailable. Selecting 'Format rows' and 'Format columns' in the protection dialog box does not restore outline functionality.
Before you start

Ensure you have the password used to protect the worksheet, as you will need to unprotect it temporarily. If you plan to use the macro solution, save a backup copy of your workbook first.

Solution 1Recommended

Use a VBA Macro to Preserve Outline Functionality

Since Excel's default protection dialog does not allow outline expansion, using a simple VBA script allows the worksheet to remain protected while keeping outline controls fully active for users.

This method uses the 'UserInterfaceOnly' parameter in VBA, which applies protection only to the user interface while allowing macros to manipulate the sheet. Combined with the 'EnableOutlining' property, this solves the grouping restriction.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) Editor in Excel.

2
Access the Workbook Module

In the Project Explorer pane on the left, find your workbook name and double-click on 'ThisWorkbook' to open its code window.

3
Enter the VBA Code

Paste the following code: Private Sub Workbook_Open() With Worksheets("Sheet1") .Protect Password:="yourpassword", UserInterfaceOnly:=True .EnableOutlining = True End With End Sub. Be sure to replace 'Sheet1' and 'yourpassword' with your actual sheet name and password.

4
Save as a Macro-Enabled Workbook

Close the VBA Editor. Go to File > Save As, and change the file format to 'Excel Macro-Enabled Workbook (*.xlsm)'. Close and reopen the file for the code to take effect.

Use a VBA Macro to Preserve Outline Functionality
Macro Security: When reopening the workbook, you must click 'Enable Content' on the security warning bar so the macro can run and activate the outline controls.
Seamless Spreadsheet Management

Easily Manage Protected Sheets with WPS Spreadsheet

WPS Spreadsheet offers robust worksheet protection and grouping tools. You can easily manage data outlines, protect sensitive information, and utilize macros in WPS Office without subscription fees.

  1. 1. Group Rows or Columns: Open your workbook in WPS Spreadsheet. Select the rows or columns you want to group, go to the 'Data' tab, and click 'Group'.
  2. 2. Protect the Worksheet: To protect the sheet, navigate to the 'Review' tab and select 'Protect Sheet'. Choose the permissions you want to grant to users.
  3. 3. Utilize WPS Macros: For advanced controls like expanding groups on a protected sheet, access the 'Developer' tab in WPS Spreadsheet to run identical VBA scripts.
100% compatible with Microsoft Excel (.xlsx, .xlsm)Advanced sheet protection to secure sensitive dataFull support for VBA macros to automate outline controlsFree, lightweight, and user-friendly interface
microsoft office alternative - wps office

Frequently Asked Questions

Why does checking 'Format rows' and 'Format columns' not allow grouping on a protected sheet?

Excel treats grouping and outlining as structural changes rather than standard cell formatting. Because there is no specific checkbox for 'Allow Outlining' in the default Protect Sheet dialog, checking formatting options does not bypass the structural restriction.

Can I apply the VBA outlining fix to multiple protected sheets at once?

Yes. In the VBA 'Workbook_Open' event, you can use a loop (e.g., 'For Each ws In ThisWorkbook.Worksheets') to apply the '.EnableOutlining = True' and '.Protect' methods to all sheets in the workbook automatically upon opening.

Will the VBA macro solution work if I share the file with colleagues?

Yes, as long as your colleagues open the file in a desktop version of Excel that supports macros and they choose to 'Enable Content' when prompted. Note that VBA macros will not function in Excel for the Web.