Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

 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

doc-auto-protect-sheet-1

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:

doc-auto-protect-sheet-2

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 60 days.

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

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

doc-auto-protect-sheet-3 3
-1
doc-auto-protect-sheet-4 4

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:

doc-auto-protect-sheet-5 5 -2 doc-auto-protect-sheet-6 6

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:

doc-auto-protect-sheet-7 7

4. In the protected worksheet, now, click the Enterprise > 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 200 handy Excel add-ins, free to try with no limitation in 60 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?


Recommended Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 71%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 82% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.