.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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
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,215,427
Messages
6,124,831
Members
449,190
Latest member
rscraig11

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