.enableAutoFilter not working in Private Sub Workbook_Open()

rjheibel

New Member
Joined
Mar 8, 2018
Messages
42
I have a protected sheet with filtering which will not allow filtering upon opening. I have the following code in ThisWorkbook... The EnableOutlining is working, but not the filtering. Any suggestions?

VBA Code:
Private Sub Workbook_Open()

With Worksheets("Design")
    .Protect Password:="Password", Userinterfaceonly:=True
    .EnableAutoFilter = True
    .EnableOutlining = True

End With
With Worksheets("Bids")
    .Protect Password:="Password", Userinterfaceonly:=True
    .EnableOutlining = True
    .EnableAutoFilter = True
End With
With Worksheets("% Complete Summary")
    .Protect Password:="Password", Userinterfaceonly:=True
    .EnableOutlining = True
    .EnableAutoFilter = True
End With
With Worksheets("Purchase Orders")
    .Protect Password:="Password", Userinterfaceonly:=True
    .EnableOutlining = True
    .EnableAutoFilter = True
End With

End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Before protecting the sheet, you should check that the autofilter on the sheet is active.
Or you can set it with the following:

For example:
VBA Code:
  With Worksheets("Purchase Orders")
    .Unprotect "Password"
    If .AutoFilterMode = False Then .Range("A1").AutoFilter
    .Protect Password:="Password", Userinterfaceonly:=True
    .EnableOutlining = True
    .EnableAutoFilter = True
  End With
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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