Note: The other languages of the website are Google-translated. Back to English

 How to auto protect a specific worksheet in Excel?

To protect the worksheet may prevent others modifying the contents of your worksheet, sometimes, you need to edit your protected worksheet. In this case, you must unprotect the worksheet first, and then protect it again after modifying the content. However, most of us may forget to protect the worksheet again after finishing the editing. This article, I will talk about some methods to solve this task about auto protecting worksheet again.

Auto protect the specific worksheet with VBA code

Auto protect the specific worksheet with Kutools for Excel

Auto protect the specific worksheet with VBA code

There are no any other direct ways for us to auto protect the specific worksheet again in Excel, so you can create a VBA code to deal with it. After modifying the contents of the worksheet, please do as follows:

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Then click ThisWorkbook from the left Project Explorer, double click it to open the Module, and then copy and paste following VBA code into the blank Module:

VBA code: Auto protect specific worksheet

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    If MsgBox("Reprotect Sheet Main?", vbYesNoCancel) = vbYes Then
        Sheets("Main").Protect ("123456")
    End If
End Sub


3. And then save and close this code, a prompt box will pop out to remind you if you want to re-protect this specific worksheet, see screenshot:


4. Then click Yes button to protect this worksheet again, now, you need to save this workbook as Excel Macro-Enabled Workbook format. From now on, when you save or close this workbook, the above prompt box will pop out each time to remind you protecting your specific worksheet automatically.

Note: In the above code, the text Main is the worksheet name that you want to re-protect, and the number 123456 is the password of your protected sheet, you can change them to your need.

Auto protect the specific worksheet with Kutools for Excel

If you have Kutools for Excel, with its Worksheet Design feature, you can quickly and easily modify the protected sheet and then re-protect it again without any VBA code.

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 30 days.

After installing Kutools for Excel, please do as following steps:

1. Go to your protected worksheet, and then click Kutools Plus > Worksheet Design, and a new Design tab will be displayed on the ribbon, see screenshots:


2. Under the Design tab, click Settings option in the Options group, and in the popped out Design Tools Settings dialog box, please check both Unprotect the worksheet before opening design tools option and Protect the worksheet before closing design tools option from the Protect section, and then enter the password of your protected worksheet into the Use Password text box, see screenshots:


3. After finishing the above settings, click OK to close the dialog, and then exit the Worksheet Design by clicking Close Worksheet Design to make this utility take effect. See screenshot:

4. In the protected worksheet, now, click the Kutools Plus > Worksheet Design to unprotect the worksheet and modify the content as you need, after editing the content, please click Close Worksheet Design to protect this worksheet again.

Download and free trial Kutools for Excel Now !

Demo: Auto protect the specific worksheet with Kutools for Excel

Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 30 days. Download and free trial Now!

Related articles:

How to protect multiple worksheets at once in Excel?

How to unprotect multiple worksheets at once in Excel?

How to set a password to protect the workbook?

The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Leave your comments
Posting as Guest
Rate this post:
0   Characters
Suggested Locations