Forum Discussion
diseydaly1983
May 13, 2020Copper Contributor
VBA.... clear filters & protect sheet (but allow auto filters) upon closing
Hi There I am creating a leave planner for my team and when someone closes it, it want it to clear any filters and protect the document (without a password) but allow auto filtering. I manage...
- May 13, 2020
Private Sub Workbook_Open() Dim ws As Worksheet For Each ws In Worksheets If ws.AutoFilterMode Then ws.AutoFilter.ShowAllData ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _ , AllowFiltering:=True Next ws End Sub
bhushan_z
May 13, 2020Iron Contributor
Private Sub Workbook_Open()
Dim ws As Worksheet
For Each ws In Worksheets
If ws.AutoFilterMode Then ws.AutoFilter.ShowAllData
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True
Next ws
End Sub- sfrancoz24Aug 18, 2020Copper Contributor
What would the code be if you need it do this but, add have to enter a password to protect the sheet when closing TIA! bhushan_z
- diseydaly1983May 13, 2020Copper Contributor