How to enable grouping in protected sheet

Many in times we are faced with a situation where in we want to enable groups in protected sheets. You want the users not to change or modify your worksheets but still you want them to see all the data which is between a group of columns or rows.

The best way to do this is to use the enable outlining property of the worksheet protect method that tells the worksheets to enable grouping even though the sheet is protected.

Use the code below to protect your sheets and to keep the grouping enabled.

Sub enableGrouping()
With Activesheet
.Protect Password:="abc", UserInterfaceOnly:=True
.EnableOutlining = True
End with
End Sub