John Darby
asked on
Excel protection, need to enable hide/unhide for users while protected
I have a routine which protects all cells in the workbook which contain formulas. I need to add to this routine an instruction to enable the user to hide/unhide. At the moment, if protection is enabled, the user cannot hide/unhide columns and rows.
Thank you!
JohnD
Thank you!
JohnD
Sub prot()
Dim rng As Range
Dim prot As Range
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.ProtectContents = True Then ws.Unprotect
ws.Cells.Locked = False
On Error Resume Next
Set prot = ws.Cells.SpecialCells(xlCellTypeFormulas, 23)
On Error GoTo 0
If Not prot Is Nothing Then
prot.Locked = True
For Each rng In prot
If rng.Parent.ProtectContents = False Then rng.Parent.Protect DrawingObjects:=False, Contents:=True, Scenarios:=False
Next
End If
Set prot = Nothing
Next
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
AllowFormattingColumns:=Tr