ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Protect worksheet from deletion (https://www.excelbanter.com/excel-discussion-misc-queries/99635-protect-worksheet-deletion.html)

Richard

Protect worksheet from deletion
 
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?

--
Richard

Dave Peterson

Protect worksheet from deletion
 
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 Structu=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.



Richard wrote:

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?

--
Richard


--

Dave Peterson


All times are GMT +1. The time now is 07:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com