ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to password protect and allow autofilter (https://www.excelbanter.com/excel-programming/415348-macro-password-protect-allow-autofilter.html)

NStarch

Macro to password protect and allow autofilter
 
I am looking for a macro to set up a protection that only allows someone to
use the AutoFilter. The protection needs to set up a password for all the
sheets at once.

I am also wanting a macro to select all of the sheets and remove the
password.

Gord Dibben

Macro to password protect and allow autofilter
 
Each sheet must have Autofilter enabled before protecting.

Sub auto_open()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
With ws
.Protect Password:="justme", userinterfaceonly:=True
.EnableAutoFilter = True
End With
Next ws
End Sub

To unprotect all sheets at once.........

Sub UnprotectAllSheets()
Application.ScreenUpdating = False
Dim N As Single
For N = 1 To Sheets.Count
Sheets(N).Unprotect Password:="justme"
Next N
Application.ScreenUpdating = True
End Sub


Gord Dibben MS Excel MVP

On Thu, 7 Aug 2008 12:30:12 -0700, NStarch
wrote:

I am looking for a macro to set up a protection that only allows someone to
use the AutoFilter. The protection needs to set up a password for all the
sheets at once.

I am also wanting a macro to select all of the sheets and remove the
password.




All times are GMT +1. The time now is 04:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com