[英]Protect one worksheet with a password from showing up
Is there a built-in way in Excel to protect just one spreadsheet in a Workbook with a Password? Excel中是否有一种内置方法来仅使用密码保护工作簿中的一个电子表格?
Something like when user ticks or selects a Control , a password is prompted before a Worksheet become visible. 当用户在控件上打勾或选择一个控件时,会在工作表可见之前提示输入密码。
If its not built into Excel, can it be implemented with VBA? 如果它不是Excel内置的,可以用VBA实施吗?
You could try this approach which: 您可以尝试以下方法:
VeryHidden
and Protected
so that it can't be unprotected - or detected - from the standard xl menus VeryHidden
和“ Protected
,以使其无法从标准xl菜单中受到保护(或无法检测到) Workbook_BeforeClose
and Workbook_Open
events Workbook_BeforeClose
和Workbook_Open
事件上重新添加此保护 Insert an Active X
checkbox and use code to check if: 插入一个
Active X
复选框并使用代码检查是否:
UnHide
the sheet. UnHide
表的密码。 ( Fred is used in this example) CheckBox code 复选框代码
Private Sub CheckBox1_Click()
Dim StrPass As String
If CheckBox1.Value Then
StrPass = Application.InputBox("Please enter the password", "Admin check")
If StrPass = "fred" Then
With ThisWorkbook.Sheets("YourSheet")
.Unprotect "fred"
.Visible = xlSheetVisible
MsgBox "Sheet unhidden!", vbInformation
End With
Else
MsgBox "wrong password", vbCritical
End If
End If
End Sub
the ThisWorkbook
module ThisWorkbook
模块
Private Sub Workbook_BeforeClose(Cancel As Boolean)
With ThisWorkbook.Sheets("YourSheet")
.Protect "fred"
.Visible = xlVeryHidden
End With
End Sub
Private Sub Workbook_Open()
With ThisWorkbook.Sheets("YourSheet")
.Protect "fred"
.Visible = xlVeryHidden
End With
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.