Filtering / Sorting a protected Sheet

maclachlan19

Board Regular
Joined
Jul 8, 2013
Messages
53
I have a autofilter table that is password protected thru some VBA code.
The code unprotects 2 sheets, refreshes the data and re-protects both sheets.
I want the user to be able to sort the data in the table using the sorts in the Autofilter.

I don't get any errors when running the code, but when I try and Sort using the dropdown in the Autofilter I get an error "The cell or chart you're trying to change is on a protected sheet. To make a change, unprotect the sheet. You might be requested to enter a password."

Code:
Worksheets("Inventory").Unprotect Password:="Parts"
Worksheets("Inv Analysis").Unprotect Password:="Parts"
Worksheets("Inventory").Range("A3").QueryTable.Refresh BackgroundQuery:=False
Sheets("Inv Analysis").PivotTables("PT6").RefreshTable
Worksheets("Inventory").Protect Password:="Parts", AllowFiltering:=True, AllowSorting:=True
Worksheets("Inv Analysis").Protect Password:="Parts", AllowFiltering:=True, AllowSorting:=True
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
How about:
VBA Code:
Worksheets("Inventory").Unprotect Password:="Parts"
Worksheets("Inv Analysis").Unprotect Password:="Parts"
Worksheets("Inventory").Range("A3").QueryTable.Refresh BackgroundQuery:=False
Sheets("Inv Analysis").PivotTables("PT6").RefreshTable
Worksheets("Inventory").Protect Password:="Parts", AllowFiltering:=True, AllowSorting:=True, AllowUsingPivotTables:=True
Worksheets("Inv Analysis").Protect Password:="Parts", AllowFiltering:=True, AllowSorting:=True, AllowUsingPivotTables:=True
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,175
Members
452,615
Latest member
bogeys2birdies

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