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

(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:
https://www.extendoffice.com/documents/excel/4224-excel-prevent-deleting-cell-contents.html

Also found a code that was meant to solve the grouping aspect but it’s not working for me:
https://www.mrexcel.com/board/threads/allow-grouping-option-on-a-protected-worksheet-workbook.479873/

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?

Thanks,
Kasia

Leave a Reply

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