muzzanoosa
New Member
- Joined
- Dec 7, 2011
- Messages
- 8
I have a couple of documents with similar requirements.
Locked (so nobody can screw up my functions/formulas)
The document will need to be accessed by all the teachers in the department to enter raw data.
Expand and collapse groups of columns (there are a LOT of columns)
Use Autofilter (There will eventually be a lot of rows)
Need the above to work on more than one sheet.
I've been using VBA, but I am by no means knowledgeable. I'm just scouring the internet and copying other peoples codes.
BUT, I can't get a 100% solution. When I turn protection on, I either get filtering with no active grouping/ungrouping, or vice versa, or one tab works perfectly and the other one has a glitch. I go in, fix the glitch, save, close reopen and find that that tab now works, but the other one now has a glitch.
I finally found a code that enables grouping on more than one sheet with protection enabled;
Private Sub Workbook_Open()
For Each ws In Sheets
With ws
.Unprotect Password:="password"
.Protect Password:="password", UserInterfaceOnly:=True
.EnableOutlining = True
End With
Next ws
End Sub
Problem is, now filtering doesn't work.
I ensure Autofilter and Sort are ticked when I protect the sheet, and it works while the file is open.
But, if I save, close and reopen the file, filtering is turned off. The arrows are still there, but they don't do anything. Groups can still be expanded and collapsed.
When I go into the protect sheet dialog, Autofilter and Sort are now unticked. I think the VBA is turning it off?
I've been trying to sort this out for 2 days now. I'm at my wits end.
Any ideas?
Thanks in advance.
Locked (so nobody can screw up my functions/formulas)
The document will need to be accessed by all the teachers in the department to enter raw data.
Expand and collapse groups of columns (there are a LOT of columns)
Use Autofilter (There will eventually be a lot of rows)
Need the above to work on more than one sheet.
I've been using VBA, but I am by no means knowledgeable. I'm just scouring the internet and copying other peoples codes.
BUT, I can't get a 100% solution. When I turn protection on, I either get filtering with no active grouping/ungrouping, or vice versa, or one tab works perfectly and the other one has a glitch. I go in, fix the glitch, save, close reopen and find that that tab now works, but the other one now has a glitch.
I finally found a code that enables grouping on more than one sheet with protection enabled;
Private Sub Workbook_Open()
For Each ws In Sheets
With ws
.Unprotect Password:="password"
.Protect Password:="password", UserInterfaceOnly:=True
.EnableOutlining = True
End With
Next ws
End Sub
Problem is, now filtering doesn't work.
I ensure Autofilter and Sort are ticked when I protect the sheet, and it works while the file is open.
But, if I save, close and reopen the file, filtering is turned off. The arrows are still there, but they don't do anything. Groups can still be expanded and collapsed.
When I go into the protect sheet dialog, Autofilter and Sort are now unticked. I think the VBA is turning it off?
I've been trying to sort this out for 2 days now. I'm at my wits end.
Any ideas?
Thanks in advance.
Last edited: