Prevent user from deleting a particular sheet

前端 未结 6 1290
春和景丽
春和景丽 2020-12-10 06:54

Protecting workbook structure will prevent a user from deleting sheets. But how could I (using VBA) prevent a user from deleting a particular sheet I designate? I\'

6条回答
  •  春和景丽
    2020-12-10 07:22

    Answer is by adding the following code to each of the protected sheets:

    Private Sub Worksheet_Deactivate()
        ThisWorkbook.Protect , True
        Application.OnTime Now, "UnprotectBook"
    End Sub
    

    And the following to a Module:

    Sub UnprotectBook()
        ThisWorkbook.Unprotect
    End Sub
    

    Check https://www.top-password.com/blog/prevent-excel-sheet-from-being-deleted/ for credits accordingly.

提交回复
热议问题