Dear all,
I recorded/edited the following code to update some pivot tables on hidden/protected sheets. The code worked fine, but suddenly I get an error that "I cannot update pivot tables on a protected sheet" (see line in bold). However, this sheet is only hidden (not protected). I already included a line to unprotect it (even it's not protected), but I keep getting the same error message.
Can someone help me on this and explain what i did wrong?
Kind regards,
Bart
Sub UpdateActuals()
'
' UpdateActuals Macro
'
ActiveSheet.Unprotect Password:="otsa"
Sheets("pivots TT actuals (1)").Visible = True
Sheets("pivots TT actuals (2)").Visible = True
Sheets("Pivots TT actuals (1)").Select
Sheets("pivots TT actuals (1)").Unprotect Password:="otsa"
Sheets("pivots TT actuals (2)").Unprotect Password:="otsa"
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable3").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable5").PivotCache.Refresh
Sheets("Pivots TT actuals (2)").Select
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
Sheets("Overzicht TT - Actuals & KPI").Select
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
Rows("61:69").Select
Selection.EntireRow.Hidden = True
Range("I15").Select
Sheets("pivots TT actuals (1)").Visible = False
Sheets("pivots TT actuals (2)").Visible = False
ActiveSheet.protect Password:="otsa"
End Sub
Bookmarks