Skip to main content
 

 How to auto protect a specific worksheet in Excel?

Author: Xiaoyang Last Modified: 2024-09-29

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

copy and paste the vba code to ThisWorkbook module

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:

a prompt box pops out to remind if want to re-protect this specific worksheet

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 offers over 300 advanced features to streamline complex tasks, boosting creativity and efficiency. Enhanced with AI capabilities, Kutools automates tasks with precision, making data management effortless. Detailed information of Kutools for Excel...         Free trial...

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:

click Worksheet Design feature of kutools
arrow down
new Design tab will be displayed on the ribbon

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:

click Settings option arrow right  check both Unprotect the worksheet before opening design tools option and Protect the worksheet before closing design tools option

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:

click Close Worksheet Design

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 !


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?

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


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!