macro - protect worksheets .....allow auto filter

bluepenink

Well-known Member
Joined
Dec 21, 2010
Messages
585
hello

wondering how i can allow the user to apply the "auto filter", while the sheet is proteted.

here is my current code:

Code:
Sub ProtectAllSheets()
Dim ws As Worksheet
    For Each ws In ThisWorkbook.Worksheets
        ws.Protect Password:="analyst", DrawingObjects:=True, _
            Contents:=True, Scenarios:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True, userinterfaceonly:=True, AllowFormattingCells:=True
            
        ws.EnableSelection = xlNoRestrictions
    Next ws
End Sub

thx you!!!!
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
i have code as well, but it's still not enabling the auto filter?

Code:
Private Sub Workbook_Open()
For c = 1 To Sheets.Count
               With Worksheets(c)
        .Protect Password:="analyst", userinterfaceonly:=True, AllowFormattingCells:=True, Contents:=True, Scenarios:=True, _
            AllowFormattingColumns:=True, AllowFormattingRows:=True
        .EnableOutlining = True
        .EnableAutoFilter = True
    End With
Next c
End Sub
 
Upvote 0
Here's how I do it . . . .
Code:
    With ActiveSheet
        .Protect Password:="PASSWORD", AllowFiltering:=True
        .EnableSelection = xlUnlockedCells
    End With
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top