[VBA] Filter macro not working in protected/shared sheet. Way around?

Metaripley

Board Regular
Joined
Dec 31, 2014
Messages
93
I have got an protected and shared sheet.
Which I want some macros to run a filter. And I cant unshare/unprotect/filter/protect/share because other users may lose data ar have to save a copy of the file. (which is bad!)

So is there a way around this problem (programmable in VBA) so I can filter in a protected file without unprotecting it?

Code:
Sub filter()'
' filtertest Macro
'


'
    ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=3, Criteria1:= _"done"
End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Maybe, before you protect it, check allow to use AutoFilter on protect worksheet option
 
Upvote 0
I found somewhat of a solution.

Instead of locking the sheet with the lock sheet button at the ribbon, I now lock it using a VBA code.

Code:
Sub Protect()

    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
        , AllowSorting:=True, AllowFiltering:=True, UserInterfaceOnly:=True


End Sub

Doing this will enable macro filtering within a protected sheet without the need of unprotecting it all the time!
 
Upvote 0

Forum statistics

Threads
1,203,072
Messages
6,053,377
Members
444,660
Latest member
Mingalsbe

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