How to set password to protect hidden sheet in Excel?
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?
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.
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:
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:
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:
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.
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:
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
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.
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 : 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 follows:
1. Click Kutools Plus > Protect Worksheet, see screenshot:
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:
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.
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.
Best Office Productivity Tools
Supercharge Your Spreadsheets： Experience Efficiency Like Never Before with Kutools for Excel
Kutools for Excel boasts over 300 features, ensuring that what you need is just a click away...
Supports Office/Excel 2007-2021 & newer, including 365 | Available in 44 languages | Enjoy a full-featured 30-day free trial.
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!