Hello there i have the following VBA in an excel sheet.
Private Sub Workbook_Open()
Application.EnableEvents = True
Worksheets("BudgetInput").Unprotect Password:="password"
Worksheets("BudgetInput").Range("G3:G150").Locked = True
MsgBox "Sheet is now UnProtected"
ActiveWorkbook.Connections("Query - MediaSubMedia").Refresh
ActiveSheet.CircleInvalid
ActiveWorkbook.Connections("Query - Media").Refresh
ActiveWorkbook.Connections("Query - BudgetData").Refresh
ActiveWorkbook.Connections("Query - TeamClients").Refresh
ActiveWorkbook.Connections("Query - BaseVersionBudget").Refresh
ActiveWorkbook.Connections("Query - F_Client_Grouping").Refresh
ActiveWorkbook.Connections("Query - CurrVersionBudget").Refresh
MsgBox "Refresh Complete"
Worksheets("BudgetInput").Range("G3:G150").Locked = False
Worksheets("BudgetInput").Protect Password:="password"
MsgBox "Sheet is now Protected"
End Sub
I have Message boxes to tell when each part completes. But when i get to the last message, "Sheet is now protected" i get the following message.
The cell or chart you're trying to change is on a protected sheet. To make a change, un-protect the sheet.
It looks like the Refreshes are not completing before i protect my sheet. Is there a way i can make sure my refreshes are complete, then run the code to protect my sheet.??
Kind Regards
Rob