- To post as a guest, your comment is unpublished.· 8 months agoMate.., it is more for ACCIDENTAL DELETION.
How to prevent a certain worksheet from being deleted in Excel?
If you want to prevent a certain worksheet from being deleted in Excel, please try the method in this article.
- Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
- More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
- Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
- Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
- Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
- Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
- More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.
The below VBA code can help you to prevent a certain worksheet from being deleted in Excel. Please do as follows.
1. Open the worksheet you don’t want it to be deleted, right click the sheet tab and click View Code from the right-clicking menu.
2. In the Microsoft Visual Basic for Applications window, please copy and paste the below VBA code into the Code window.
VBA code: Prevent a certain worksheet from being deleted in Excel
Private Sub Worksheet_Activate() ThisWorkbook.Protect "yourpassword" End Sub Private Sub Worksheet_Deactivate() ThisWorkbook.Unprotect "yourpassword" End Sub
Note: In the code, please replace the content “yourpassword” with your real password.
3. Press the Alt + Q keys simultaneously to close the Microsoft Visual Basic for Applications window.
4. Shift to another worksheet and go back to this worksheet again to activate the VBA code.
5. Right click the sheet tab, you can see the Delete option is gray and disabled among the options as below screenshot shown.
- How to prevent specific cell contents from being deleted in Excel?
- How to prevent selection of multiple worksheets in Excel?
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
- To post as a guest, your comment is unpublished.· 1 years agohmm.. but after you do that everyone can still click on "view code" and see the password. what is the password for? how can you delete the sheet using the password?
- To post as a guest, your comment is unpublished.· 2 years agoThis does not prevent worksheet deletion. Add an extra sheet, select the new sheet as the primary, the "protected" sheet as a secondary selection and delete. Bye-bye "protected" sheet.