Musical2018
New Member
- Joined
- Apr 2, 2018
- Messages
- 2
I am new to MrExcel and new to VBA and hope you will help me. I used the following code to protect my workbook sheets before close and upon save and it works great but I can't figure out how to write it to allow filters to still work on all tabs of the workbook when protected. There are several people using it and I need to be sure it doesn't get left unprotected but they need to be able to filter.
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim ws As Worksheet
Const ccbsox As String = "ccbsox"
For Each ws In ThisWorkbook.Worksheets
ws.Protect Password:="ccbsox"
Next ws
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim ws As Worksheet
Const ccbsox As String = "ccbsox"
For Each ws In ThisWorkbook.Worksheets
ws.Protect Password:="ccbsox"
Next ws
End Sub
Last edited by a moderator: