Forum Discussion
Mick_Kitcher
May 06, 2023Copper Contributor
Using Group-Ungroup in a protected Excel sheet
what do i need t do to enable me to group and ungroup rows in my spreadsheet without having to unprotect it? Any help most welcome, thank you.
didierengelbosch
Aug 02, 2024Copper Contributor
HansVogelaar thanks for this!
I am using a workbook with tens of tabs. I would like to apply the code to a selection of tabs without having to list them all in the code because 1)many 2)I might have to add and delete tabs and hence want to avoid having to hardcode them in the code. Is it possible to use a list of tabs without having to hardcode them individually in de code?
ps: I have a tab with a list of all tabs, and I have created a named range with the tabs I would like to protect. It if might help…
HansVogelaar
Aug 02, 2024MVP
Let's say that you named the range with the tabs to protect ToProtect. The code could then look like this:
Private Sub Workbook_Open()
Dim rng As Range
For Each rng In Range("ToProtect")
With Worksheets(rng.Value)
.Protect Password:="Secret", UserInterfaceOnly:=True
.EnableOutlining = True
End With
Next rng
End Sub
- didierengelboschAug 08, 2024Copper Contributor
HansVogelaar thanks a lot! Works fine!