Protect worksheet from deletion

R

Richard

Is there a way to password protect one worksheet from being deleted, while
allowing users to add new worksheets?

Failing that, is there a way to password protect one worksheet from being
deleted, while allowing a macro program to add a new sheet?
 
D

Dave Peterson

Protect the workbook and provide a macro that unprotects the workbook, adds a
sheet and then reprotects the workbook.

Option Explicit
Sub testme02()
With ThisWorkbook
.Protect Password:="hi there"
.Worksheets.Add
.Protect Structure:=True, Windows:=False, Password:="hi there"
End With
End Sub

Just a warning: workbook protection like this is easily broken.


Remember to protect the project in the VBE, else others will see the password in
the code.

Tools|VBAProject Properties|Protection tab
Lock the project for viewing and give it a memorable password.
 
Top