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?
Group and ungroup rows in a protected worksheet with VBA code
Group and ungroup rows in a protected worksheet with VBA code
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.
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!












