Protected sheet and pivot tables

MartinL

Well-known Member
Joined
Oct 16, 2008
Messages
1,141
Office Version
  1. 365
Platform
  1. Windows
Apologies for raising this old chestnut but I have not been able to find a workable solution from any of the threads here.

I have a protected sheet (no password) with a pivot table and some slicers on, along with some charts that I don't want messed up.

I have unchecked the LOCKED properties option on the slicers
I have nothing checked on the protect sheet properties (except the protect worksheet and contents of locked cells)

I have a piece of vba that says
Code:
Private Sub Worksheet_PivotTableChangeSync(ByVal Target As PivotTable)
ActiveSheet.Unprotect
Worksheets("Management Report").Columns("D:AA").AutoFit
ActiveSheet.Protect , UserInterfaceOnly:=True
End Sub
But I get "Cannot edit PivotTable on protected sheet"

stepping through shows that this error message displays happens before the vba is run.
I've tried all the Worksheet - Options ie Worksheet_SelectionChange etc but none have any effect on allowing the pivot table to change.

Is this even possible, then?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
SOLVED, A good nights sleep later....
The issue was that there was a check box missing on the worksheet option.
AllowUsingPivotTables:=True

so rewirite like this
Code:
Private Sub Worksheet_PivotTableChangeSync(ByVal Target As PivotTable)
ActiveSheet.Unprotect
Worksheets("Management Report").Columns("D:AA").AutoFit
ActiveSheet.Protect , UserInterfaceOnly:=True, AllowUsingPivotTables:=True
End Sub

and it works as expected
 
Upvote 0

Forum statistics

Threads
1,223,948
Messages
6,175,570
Members
452,652
Latest member
eduedu

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