View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default 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.