GaryHinton
New Member
- Joined
- Jun 13, 2016
- Messages
- 18
- Office Version
- 365
- Platform
- Windows
Sub ap()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Dim Sh As Worksheet
Dim pvt As PivotTable
Dim nm As String
For Each Sh In Sheets
Sh.Unprotect "ABC"
Next
For Each Sh In Sheets
For Each pvt In Sh.PivotTables
nm = Sh.Name
pvt.PivotCache.Refresh
Next
Next
For Each Sh In Sheets
Sh.Protect "ABC", _
DrawingObjects:=False, _
Contents:=True, _
Scenarios:=False, _
AllowSorting:=True, _
AllowFiltering:=True, _
AllowFormattingCells:=True, _
AllowUsingPivotTables:=True
Sh.EnableSelection = xlUnlockedCells
For Each Sheet In Sheets
Sheet.Activate
ActiveWindow.DisplayGridlines = False
Next Sheet
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
End Sub
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Dim Sh As Worksheet
Dim pvt As PivotTable
Dim nm As String
For Each Sh In Sheets
Sh.Unprotect "ABC"
Next
For Each Sh In Sheets
For Each pvt In Sh.PivotTables
nm = Sh.Name
pvt.PivotCache.Refresh
Next
Next
For Each Sh In Sheets
Sh.Protect "ABC", _
DrawingObjects:=False, _
Contents:=True, _
Scenarios:=False, _
AllowSorting:=True, _
AllowFiltering:=True, _
AllowFormattingCells:=True, _
AllowUsingPivotTables:=True
Sh.EnableSelection = xlUnlockedCells
For Each Sheet In Sheets
Sheet.Activate
ActiveWindow.DisplayGridlines = False
Next Sheet
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
End Sub