VBA -- protecting my sheet

  • Thread starter Thread starter Josh
  • Start date Start date
J

Josh

Is there a way to use VBA to automatically lock (protect) my sheet every 2
hours? Only certain employees are allowed to modify it, and they are
forgetting to lock it at the end of their shift. So far I have come up with
this:

Sub ProtectSheet()

ActiveSheet.Protect (password)

End Sub

Can anyone point me towards a source of info on how to do this at 2 hour
intervals?

Thanks in advance...
 
I will never argue with Chip Pearson or John McGimpsey. Good to see Chip
back again.
Is Frank Kabel on holidays?
Anyway Gosh in stead of "on time" you may want to consider to protect the
sheets before closing, before saving and "before opening"

Sub Seal_File()

For Each sheet In Sheets
On Error Resume Next
sheet.Protect ("spw")
Next
Application.StatusBar = ""
End Sub

Sub UNSEAL()
'you could give this macro a key combination ..............
ActiveWorkbook.Unprotect ("spw")
For Each sheet In Sheets
On Error Resume Next
sheet.Unprotect ("spw")
Next
Application.StatusBar = "NOT sealed"
End Sub

Note the application status bar commands
that way you will see at the bottom of the sheet whether the sheet is in the
unprotected mode.

Regards
Bill K
 
Oops Josh

I forgot to delete the line
ActiveWorkbook.Unprotect ("spw")
in the unseal macro.
It probably will give you an error........... if the workbook is not
protected in the first place.

Bill K
 
Yes I already did!

Had the greatest respect for him and always wondered how he could answer so
many queries in all newsgroups.

Bill K
 
Back
Top