Skip to main content
 

How to set password to protect hidden sheet in Excel?

Author: Xiaoyang Last Modified: 2024-09-03

If you have a workbook which contains some important hidden worksheets, and do not allow others to unhide them. Now, you need to set a password to protect the hidden worksheets completely, when other users unhide them, they must enter the password. Do you have any ways to deal with this task quickly and easily in Excel?

Set password to protect hidden sheets with VeryHidden function

Set password to protect hidden sheet with VBA code

Protect multiple worksheets at once with Kutools for Excel


Set password to protect hidden sheets with VeryHidden function

Normally, you can use the VeryHidden function to hide the worksheets first, and then set a password for them, please do as following steps:

1. Open your workbook, and hold Alt + F11keys to open the Microsoft Visual Basic for Applications window.

2. In the Microsoft Visual Basic for Applications window, click View > Project Explorer and Properties Window to display their panes.

click View > Project Explorer and Properties Window to display the panes

3. And then in the Project-VBAProject pane, choose the worksheet that you want to hide, and in the Properties pane, click the drop down list from the Visible section to select xlSheetVeryHidden option, see screenshot:

select xlSheetVeryHidden in the Properties pane

4. After making the worksheet veryhidden, you can set a password to protect it. In the Microsoft Visual Basic for Applications window, click Insert > Module to open an empty module, and then click Tools > VBAProject Properties, see screenshot:

click Tools > VBAProject Properties

5. Then in the popped out VBAProject-Project Properties dialog box, click Protection tab, and then check Lock project for viewing box, finally, enter and confirm the password in the Password to view project properties section, see screenshot:

set options in the dialog box

6. Then click OK button to exit this dialog, and close the Microsoft Visual Basic for Applications window.

7. Save the workbook as Excel Macro-Enabled Workbook format and close it to make the password protection take effect.

Save the workbook as Excel Macro-Enabled Workbook format

8. Next time, when you open this workbook, and want to make the veryhidden sheets be visible, you are requested to enter a password. See screenshot:

make the veryhidden sheets be visible, you are requested to enter a password


Demo: Set password to protect hidden sheets

 
a screenshot of kutools for excel ai

Unlock Excel Magic with Kutools AI

  • Smart Execution: Perform cell operations, analyze data, and create charts—all driven by simple commands.
  • Custom Formulas: Generate tailored formulas to streamline your workflows.
  • VBA Coding: Write and implement VBA code effortlessly.
  • Formula Interpretation: Understand complex formulas with ease.
  • Text Translation: Break language barriers within your spreadsheets.
Enhance your Excel capabilities with AI-powered tools. Download Now and experience efficiency like never before!

Set password to protect hidden sheet with VBA code

To set a password to protect the hidden sheets, I can also talk about a VBA code for you.

1. Hide one worksheet that you want to protect.

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

3. Then choose 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: Set password to protect hidden sheet

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim xSheetName As String
xSheetName = "Sheet1"
If Application.ActiveSheet.Name = xSheetName Then
    Application.EnableEvents = False
    Application.ActiveSheet.Visible = False
    xTitleId = "KutoolsforExcel"
    response = Application.InputBox("Password", xTitleId, "", Type:=2)
    If response = "123456" Then
        Application.Sheets(xSheetName).Visible = True
        Application.Sheets(xSheetName).Select
    End If
End If
Application.Sheets(xSheetName).Visible = True
Application.EnableEvents = True
End Sub

copy and paste the code into the ThisWorkbook module

Note: In the above code, Sheet1 of the xSheetName = "Sheet1" script is the hidden worksheet name that you want to protect, and 123456 in the If response = "123456" Then script is the password that you set for the hidden sheet. You can change them to your need.

4. Now, when you want to show the hidden sheet, a prompt box will pop out to let you enter the password. And this prompt box will appear each time, when you click to show the hidden sheet.

make the veryhidden sheets be visible, you are requested to enter a password


Protect multiple worksheets at once with Kutools for Excel

If you want to protect multiple selected or all worksheets of a workbook at once, normally, you need to protect one by one manually in Excel. But, if you have Kutools for Excel, with its Protect Worksheet utility, you can protect them with one click.

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 follows:

1. Click Kutools Plus > Protect Worksheet, see screenshot:

click Protect Worksheet feature of kutools

2. In the Protect Worksheet dialog box, all worksheets within the workbook are listed into the list box, please choose the worksheets that you want to protect. See screenshot:

choose the worksheets that you want to protect

3. And then click OK, in the following dialog box, please enter your password and retype it again, then click OK, another prompt box will pop out to remind you how many worksheets have been protected.

enter a password and retype it

4. Then click OK to close the dialogs, and all of the worksheets in the workbook have been protected with the same password.

Note: If you want to unprotect all of the worksheets at once, you just need to click Kutools Plus > Unprotect Worksheet, and type your password to cancel the protection.

click Kutools Plus > Unprotect Worksheet to cancel the protection

 Download and free trial Kutools for Excel Now !


Related articles:

How to protect multiple worksheets at once in Excel?

How to set a password to protect the workbook?

How to protect / lock VBA code in Excel?

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!