Can I password protect the below macro to run between 8.30am and 6pm?
with a message like "Please enter password to refresh the pivot tables between 8.30am and 6.00pm"
But however the I need macro to run without the need of the password between 6.01pm and 8.29am.
with a message like "Please enter password to refresh the pivot tables between 8.30am and 6.00pm"
But however the I need macro to run without the need of the password between 6.01pm and 8.29am.
Code:
Sub AllSheetsRefresh()
Application.ScreenUpdating = False
For Each Worksheet In Worksheets
Worksheet.Unprotect Password:="mypassword"
Next Worksheet
For Each PivotCache In ActiveWorkbook.PivotCaches
PivotCache.Refresh
Next
For Each Worksheet In Worksheets
Worksheet.Protect Password:="mypassword", _
DrawingObjects:=True, _
Contents:=True, _
Scenarios:=True, _
UserInterfaceOnly:=True, _
AllowFormattingCells:=False, _
AllowFormattingColumns:=False, _
AllowFormattingRows:=False, _
AllowInsertingColumns:=False, _
AllowInsertingRows:=False, _
AllowInsertingHyperlinks:=False, _
AllowDeletingColumns:=False, _
AllowDeletingRows:=False, _
AllowSorting:=False, _
AllowFiltering:=True, _
AllowUsingPivotTables:=True
Next Worksheet
Application.ScreenUpdating = True
End Sub