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?


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