(Solved) – Protecting some ranges from editing and deleting but allowing to use grouping


I need to have a macro will protect some ranges in my excel file from editing and deleting.
At the same time I need to use filtering, sorting and grouping.

Have already fund solution for preventing the some cells from deleting:

Also found a code that was meant to solve the grouping aspect but it’s not working for me:

Private Sub Workbook_Open()
With Worksheets("Sheet1")
.Unprotect "tnskmg"
.EnableOutlining = True
.Protect "tnskmg", contents:=True, userInterfaceOnly:=True
End With

End Sub

Do you know what can be possibly a reason the code is not working?


Leave a Reply

Your email address will not be published. Required fields are marked *