Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Protecting sheets; macros VBA

Status
Not open for further replies.

oggsta

Technical User
Joined
Jun 22, 2002
Messages
41
Location
GB
I am trying to automatically protect a worksheet with a password, when a file is either closed or saved. This will avoid people forgetting to protect the sheet after it has been modified.

Is it possible to write a VBA script to enable this to happen, if possible could you please advise on the code.

I.e. once the user save or closes the files.
the code or macro automatically kicks into gear to protect the workbook.

Any help much appreciated.


Regards

 
Just use the BeforeSave event with

sheets("Sheetname").protect password:="passwordgoeshere"

as the line of code Rgds
Geoff
"Some cause happiness wherever they go; others whenever they go."
-Oscar Wilde
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top