Unable to sort on protected sheet

honkin

Active Member
Joined
Mar 20, 2012
Messages
374
Office Version
  1. 2016
Platform
  1. MacOS
I have a template I use to create new results sheets. The first 16 rows are locked and have boxes with Profit & Loss and other metrics and the data headers are in row 17 with the data all starting from row 18.

As I said, the first 16 rows are locked and when I protect the sheet, I select the things to allow, like Sort, Filter & Select Unlocked Cells, yet when I click on the Data menu, Filter is greyed out.

Any ideas why this is the case and how is it possible to have the sheet perform as I wish?

cheers
 
Let me know if this works for you.

VBA Code:
Option Explicit

Sub ClearFilters()
    Dim ws As Worksheet
   
    For Each ws In Worksheets
        If ws.AutoFilterMode Then
            ws.AutoFilter.ShowAllData
            ActiveSheet.Protect Contents:=True, AllowFiltering:=True
        Else
            MsgBox "No AutoFilter detected on ." & ws
        End If
    Next ws
End Sub
 
Upvote 0
Solution

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Let me know if this works for you.

VBA Code:
Option Explicit

Sub ClearFilters()
    Dim ws As Worksheet
  
    For Each ws In Worksheets
        If ws.AutoFilterMode Then
            ws.AutoFilter.ShowAllData
            ActiveSheet.Protect Contents:=True, AllowFiltering:=True
        Else
            MsgBox "No AutoFilter detected on ." & ws
        End If
    Next ws
End Sub
Excellent antman2988. I will see how it goes and let you know

cheers and thanks so much
 
Upvote 0
The code I posted should still work on one sheet. Let me know if it doesn't.
Just got a chance to test this and it seems to work fine, make all the contents now appear and keeping the autofilter active

Thanks so much
 
Upvote 0

Forum statistics

Threads
1,215,480
Messages
6,125,050
Members
449,206
Latest member
Healthydogs

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