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."
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