How to group and ungroup rows in protected worksheet?
As we all known, in a protected worksheet, there are many limitations for us to apply some operations. Such as, we can’t toggle between grouped and ungrouped data. Is there a way to group or ungroup rows in a protected worksheet?
- Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
- More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
- Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
- Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
- Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
- Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
- More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.
Maybe, there is no other good way to solve this problem but using a VBA code, please do as follows:
1. Activate your worksheet that you want to use, please make sure the worksheet is not protected yet.
2. Then hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
3. Click Insert > Module, and paste the following code in the Module Window.
VBA code: Group and ungroup rows in a protected worksheet
Sub EnableOutlining() 'Update 20140603 Dim xWs As Worksheet Set xWs = Application.ActiveSheet Dim xPws As String xPws = Application.InputBox("Password:", xTitleId, "", Type:=2) xWs.Protect Password:=xPws, Userinterfaceonly:=True xWs.EnableOutlining = True End Sub
4. Then press F5 key to run this code, and a prompt box will pop out to remind you entering the password to protect the current worksheet. See screenshot:
5. Then click OK, your worksheet has been protected, but you can expand and contract the outline symbols in this protected worksheet, see screenshot:
Note: If your worksheet is protected already, this code will not work.