Can anyone help with this VBA issue .....
I have 7 sheets in a workbook (1 data table and 6 worksheets housing pivot tables/charts (PivotTable1) all running off the data table in sheet 1).
I am trying to write this code to enable pivot table refresh when data is inputted into the data table followed by a protection of the sheet(s). The code will unprotect the sheet prior to the refresh before protection after the refresh.
Code below:
Module1:
ThisWorkbook:Please Login or Register to view this content.
(nothing within the individual sheet code boxes)Please Login or Register to view this content.
When I input data into the data table then click on the immediate sheet following the data table (sheet 2), the pivot refreshes fine and protects. However, as I click on the other sheets I get the following error code:
Run-time error '1004'
That command cannot be performed while a protected sheet contains another pivot table report based on the same source data.
To remove protection from the sheet that has the other report, click the sheet tab, and then click unprotect sheet (review tab, changes group). Then try the command again.
I am able to click on 'End', 'Debug' and 'Help'.
Clicking on End allows the sheet refresh, however I still get the error on the pages when clicking on them.
The debug highlights 'pvt.RefreshTable' in the refresh code in Module1.
It seems the error is a direct result of the sheets already being protected somehow (a beginners assumption).
Can anyone help with the problem?
Thanks
Luke
Bookmarks