Enable Autofilter while sheet is protected

jjt1973

New Member
Joined
Jun 8, 2011
Messages
32
I have a spreadsheet that needs to be protected to protect the many formulas I have going on. This spreadsheet will be distributed as a template to multiple people. I have an autofilter running in the range A8:A52 where rows uhide when "Value does not equal 0". I have the following macro running to auto update the filter if data changes which is working great:

Private Sub Worksheet_Calculate()

If Me.FilterMode = True Then
With Application
.EnableEvents = False
.ScreenUpdating = False
End With

With ActiveWorkbook
.CustomViews.Add ViewName:="Mine", RowColSettings:=True
Me.AutoFilterMode = False
.CustomViews("Mine").Show
.CustomViews("Mine").Delete
End With


With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End If

End Sub

The problem is, I have tried these macros to enable the filter to work when the sheet is protected but they aren't working and actually disrupt my data.. The two macros I have tried look like:

Private Sub Workbook_Open()
'check for filter, turn on if none exists
With Worksheets("Data")
If Not .AutoFilterMode Then
.Range("A1").AutoFilter
End If
.EnableAutoFilter = True
.Protect Password:="test1", _
Contents:=True, UserInterfaceOnly:=True
End With
End Sub


and

Private Sub Workbook_Open()
CCW.Protect Password:="test", DrawingObjects:=True, _
contents:=True, Scenarios:=True, _
userinterfaceonly:=True
CCW.EnableAutoFilter = True
End Sub
End Sub

CCW is the name for sheet one...

Also, I do have "use autofilters" checked in the protection menu. I am really hoping somebody can help me as I feel as if I have tried everthing.

Thanks,
jjt
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
EDIT: Nevermind, I missed your second to last line which says you checked "Use Autofilter"....

I fiddled around a bit and the issue seems that the Use Autofilter will only allow the manipulation of the filter, not the adding or removing of it..
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,834
Members
452,947
Latest member
Gerry_F

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