Dear VBA Experts,
What I need is: Enable outlining and use of filters on multiple protected sheets with password (it should not be the complete workbook).
I am completely new with VBA and the VBA codes below I found via google. I searched my problem via google too, but I can't find the right COMLETE answer. I hope you can help me.
The code below works perfect, but this code is for all sheets. I only want it for a few sheets.
I only want to do it for a few sheets. So I tried the following.. but I get an error at the row where I added "(Array...)".
Can someone please help?
Thanks in advance!
What I need is: Enable outlining and use of filters on multiple protected sheets with password (it should not be the complete workbook).
I am completely new with VBA and the VBA codes below I found via google. I searched my problem via google too, but I can't find the right COMLETE answer. I hope you can help me.
The code below works perfect, but this code is for all sheets. I only want it for a few sheets.
Code:
Private Sub Workbook_Open()
For Each Sheet In Worksheets
Sheet.Unprotect Password:="User2015"
Sheet.EnableOutlining = True
Sheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowSorting:=True, AllowFiltering:=True, _
Password:="User2015", UserInterfaceOnly:=True
Next
End Sub
Code:
Private Sub Workbook_Open()
For Each Sheet In Worksheets(Array("Sheet1", "Sheet2", "Sheet3"))
Sheet.Unprotect Password:="User2015"
Sheet.EnableOutlining = True
Sheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowSorting:=True, AllowFiltering:=True, _
Password:="User2015", UserInterfaceOnly:=True
Next
End Sub
Thanks in advance!
Last edited by a moderator: