Hello,
I have the following code which i have to protect my workbook and allow filtering.
If I open my unprotected workbook and run this protection code, I am allowed to use autofilters which I have setup as buttons. If I close my protected workbook and then reopen, I am then not allowed to use the macro autofilter buttons, I need to unprotect the workbook - I can protect it straight away and all is normal again.
At the moment I have set the workbook to unprotect on close and protect on open but is this necessary?
As always, any help greatly appreciated.
Tom
I have the following code which i have to protect my workbook and allow filtering.
Code:
Sub ProtectSheets()
Dim wsheet As Worksheet
For Each wsheet In ActiveWorkbook.Worksheets
If wsheet.NAME <> "TB - EPM" And wsheet.NAME <> "ACT - GLORY" And wsheet.NAME <> "ACT - BARC" And wsheet.NAME <> "ACT - 3C" _
And wsheet.NAME <> "MHGL" Then
wsheet.Protect Password:="12345", UserInterfaceOnly:=True, AllowSorting:=True, AllowFiltering:=True
Else
End If
Next wsheet
End Sub
If I open my unprotected workbook and run this protection code, I am allowed to use autofilters which I have setup as buttons. If I close my protected workbook and then reopen, I am then not allowed to use the macro autofilter buttons, I need to unprotect the workbook - I can protect it straight away and all is normal again.
At the moment I have set the workbook to unprotect on close and protect on open but is this necessary?
As always, any help greatly appreciated.
Tom
Last edited: