I have a pivot table that automatically refreshes on sheet activation, with data from another tab which is protected. Even though I unprotect the tab prior to refreshing, I still get:
Run-time error '1004':
Cannot edit PivotTable on protected sheet.
My VBA:
Private Sub Worksheet_Activate()
Sheets("Extract").Unprotect "password"
ActiveSheet.PivotTables("pvt_Activity").PivotCache.Refresh
Sheets("Extract").Protect Password:="password", Contents:=True, Scenarios:=True
End Sub
Banging my head against a wall - why is this not working?
Cheers