跳到主要内容

如何设置密码以保护Excel中的隐藏工作表?

如果您的工作簿包含一些重要的隐藏工作表,并且不允许其他人取消隐藏它们。 现在,您需要设置一个密码来完全保护隐藏的工作表,其他用户取消隐藏它们时,他们必须输入密码。 您是否有任何方法可以在Excel中快速轻松地处理此任务?

设置密码以使用VeryHidden功能保护隐藏的工作表

设置密码以使用VBA代码保护隐藏的工作表

使用 Kutools for Excel 同时保护多个工作表


设置密码以使用VeryHidden功能保护隐藏的工作表

通常,您可以使用VeryHidden函数先隐藏工作表,然后为它们设置密码,请执行以下步骤:

1。 打开工作簿,然后按住 Alt + F11键键打开 Microsoft Visual Basic for Applications窗口.

2。 在 Microsoft Visual Basic for Applications窗口,单击“ 查看 > 项目浏览器 属性窗口o显示其窗格。

文档保护隐藏表 01

3. 然后在 项目-VBA项目 窗格中,选择要隐藏的工作表,然后在 查看房源 窗格中,单击 可见 选择部分 xlSheet非常隐藏 选项,请参见屏幕截图:

文档保护隐藏表 02

4。 使工作表非常隐藏之后,您可以设置密码来保护它。 在里面 Microsoft Visual Basic for Applications窗口,单击“ 插页 > 模块 打开一个空的模块,然后单击 工具 > VBAProject属性,请参见屏幕截图:

文档保护隐藏表 03

5。 然后在弹出 VBAProject-项目属性 对话框,单击 的故事 选项卡,然后检查 锁定项目以供查看 框,最后,输入并确认密码 查看项目属性的密码 部分,请参见屏幕截图:

文档保护隐藏表 04

6。 然后点击 OK 按钮退出此对话框,然后关闭 Microsoft Visual Basic for Applications窗口。

7。 将工作簿另存为 Excel启用宏的工作簿 格式化并关闭它以使密码保护生效。

文档保护隐藏表 05

8。 下次,当您打开此工作簿并希望使隐藏的工作表可见时,要求您输入密码。 看截图:

文档保护隐藏表 06


演示:设置密码以保护隐藏的工作表


设置密码以使用VBA代码保护隐藏的工作表

要设置密码来保护隐藏的工作表,我还可以为您介绍一个VBA代码。

1。 隐藏一个您要保护的工作表。

2。 按住 ALT + F11 键打开 Microsoft Visual Basic for Applications窗口.

3。 然后选择 的ThisWorkbook 从左边 项目浏览器,双击以打开 模块,然后将以下VBA代码复制并粘贴到空白模块中:

VBA代码:设置密码以保护隐藏的工作表

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

文档保护隐藏表 07

备注:在上面的代码中, Sheet1 xSheetName =“ Sheet1” 脚本是您要保护的隐藏工作表名称,并且 123456 ,在 如果响应=“ 123456”,则 脚本是您为隐藏工作表设置的密码。 您可以根据需要更改它们。

4。 现在,当您要显示隐藏的工作表时,将弹出一个提示框,让您输入密码。 每次单击以显示隐藏的工作表时,都会出现此提示框。

文档保护隐藏表 08


使用 Kutools for Excel 同时保护多个工作表

如果要一次保护一个工作簿的多个选定的或所有的工作表,通常,您需要在Excel中一个接一个地手动保护。 但是,如果你有 Kutools for Excel,其 保护工作表 实用程序,您可以一键保护它们。

Kutools for Excel : 带有300多个便捷的Excel加载项,可以在30天内免费试用

安装后 Kutools for Excel,请执行以下操作:

1。 点击 Kutools 加 > 保护工作表,请参见屏幕截图:

2。 在 保护工作表 对话框中,工作簿中的所有工作表都列在列表框中,请选择要保护的工作表。 看截图:

文档保护隐藏表 010

3。 然后点击 OK,请在以下对话框中输入您的密码,然后再次输入该密码,然后单击 OK,将弹出另一个提示框,提醒您已保护了多少个工作表。

文档保护隐藏表 011

4。 然后点击 OK 关闭对话框,并且工作簿中的所有工作表均已使用相同的密码保护。

请注意: 如果要一次取消保护所有工作表,只需单击 Kutools 加 > 取消保护工作表,然后输入密码以取消保护。

 立即下载和免费试用Excel的Kutools!


相关文章:

如何在Excel中一次保护多个工作表?

如何设置密码来保护工作簿?

如何在Excel中保护/锁定VBA代码?

最佳办公生产力工具

热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

kte选项卡201905


Office Tab 为 Office 带来选项卡式界面,让您的工作更加轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!
Comments (10)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
jak ktoś ukrył arkusz jak w opisanym pierwszym sposobie, a nie znamy hasła to jak odkryć arkusz skoro hasło do visual basic jest w ukrytym arkuszu?
This comment was minimized by the moderator on the site
Hello, ciekawa

Sorry, at present, there is no good way for canceling the protect of the hidden sheet if you forget the password.

But, you can apply the Uhide all hidden sheets feature of Kutools for Excel to unhide all the hidden sheets without any password.
https://www.extendoffice.com/images/stories/comments/comment-skyyang/doc-unhide-sheets.png
You can download Kutools for Excel and use it freely for 30 days.
Please have a try. Thank you!
This comment was minimized by the moderator on the site
This is elegant. IF the person opening the spreadsheet does not enable macros (i.e. VBA) what happens? Is the hidden sheet a sitting duck? Or is it quite impossible to find?
This comment was minimized by the moderator on the site
Hi, David,
If you open the workbook without enabling the macro, the hidden sheet is displayed as normal. In this case, I recommend you to apply the first method for solving this job.
Thank you!
This comment was minimized by the moderator on the site
Your code allows users to view the sheet as long as they hold the left mouse button while the mouse pointer is on the tab. Try this to keep sheet hidden until correct password is entered: If response = "123456" Then Application.Sheets(xSheetName).Visible = True Application.Sheets(xSheetName).Select Else Application.Sheets(xSheetName).Visible = False[/b][/b] End If End If Application.EnableEvents = True End Sub
This comment was minimized by the moderator on the site
I have a question about your password restricted worksheet code. You posted the following code which works....what I am looking for is code that will do this with multiple worksheets and multiple passwords within the same workbook. Is this possible? Private Sub Workbook_SheetActivate(ByVal Sh As Object) 'Update 20140925 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
This comment was minimized by the moderator on the site
Found a solution yet?

I am having the same problem
This comment was minimized by the moderator on the site
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim aSheetName As String
Dim bSheetName As String
Dim cSheetName As String
aSheetName = "sheet1"
bSheetName = "sheet2"
cSheetName = "sheet3"

If Application.ActiveSheet.Name = aSheetName Then
Application.EnableEvents = False
Application.ActiveSheet.Visible = False
xTitleId = "KutoolsforExcel"
response = Application.InputBox("Password", xTitleId, "", Type:=2)
If response = "123" Then
Application.Sheets(aSheetName).Visible = True
Application.Sheets(aSheetName).Select
Else
Application.Sheets(aSheetName).Visible = False
End If
End If
Application.EnableEvents = True

If Application.ActiveSheet.Name = bSheetName Then
Application.EnableEvents = False
Application.ActiveSheet.Visible = False
xTitleId = "KutoolsforExcel"
response = Application.InputBox("Password", xTitleId, "", Type:=2)
If response = "456" Then
Application.Sheets(bSheetName).Visible = True
Application.Sheets(bSheetName).Select
Else
Application.Sheets(bSheetName).Visible = False
End If
End If
Application.EnableEvents = True

If Application.ActiveSheet.Name = cSheetName Then
Application.EnableEvents = False
Application.ActiveSheet.Visible = False
xTitleId = "KutoolsforExcel"
response = Application.InputBox("Password", xTitleId, "", Type:=2)
If response = "789" Then
Application.Sheets(cSheetName).Visible = True
Application.Sheets(cSheetName).Select
Else
Application.Sheets(cSheetName).Visible = False
End If
End If
Application.EnableEvents = True

End Sub
This comment was minimized by the moderator on the site
Thanks for the code, just have one question. When you open the sheet you are asked for question, then you enter it and the sheet is visible, but when you jump to next sheet and try to re-open previous sheet, you are asked for the same password again everytime. My question is can you bypass that and make excel ask for password once?
This comment was minimized by the moderator on the site
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim xSheetName As String
aSheetName = "sheet1"
bSheetName = "sheet2"
cSheetName = "sheet3"

If Application.ActiveSheet.Name = aSheetName Then
Application.EnableEvents = False
Application.ActiveSheet.Visible = False
xTitleId = "KutoolsforExcel"
response = Application.InputBox("Password", xTitleId, "", Type:=2)
If response = "1234" Then
Application.Sheets(aSheetName).Visible = True
Application.Sheets(aSheetName).Select
Else
Application.Sheets(aSheetName).Visible = False
End If
End If
Application.EnableEvents = True

If Application.ActiveSheet.Name = bSheetName Then
Application.EnableEvents = False
Application.ActiveSheet.Visible = False
xTitleId = "KutoolsforExcel"
response = Application.InputBox("Password", xTitleId, "", Type:=2)
If response = "2345" Then
Application.Sheets(bSheetName).Visible = True
Application.Sheets(bSheetName).Select
Else
Application.Sheets(bSheetName).Visible = False
End If
End If
Application.EnableEvents = True

If Application.ActiveSheet.Name = cSheetName Then
Application.EnableEvents = False
Application.ActiveSheet.Visible = False
xTitleId = "KutoolsforExcel"
response = Application.InputBox("Password", xTitleId, "", Type:=2)
If response = "3456" Then
Application.Sheets(cSheetName).Visible = True
Application.Sheets(cSheetName).Select
Else
Application.Sheets(cSheetName).Visible = False
End If
End If
Application.EnableEvents = True

End Sub
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations