Excel中的多个权限图层
我目前正在Excel中的项目仪表板上工作,我需要有两层访问: – 第1层:pipe理员。 这是密码保护用户不应该触摸的所有单元格。 第2层:项目pipe理器这是为了使具有特定工作表的密码的项目经理能够编辑某些范围。
本质上我想locking工作表,但有一个额外的密码来解锁工作表上的几个单元格。
这可能吗? 我在这里和谷歌search环顾四周,但没有发现什么有用的。
谢谢你的时间! 乔尔
最简单的入门方法(另一种采用非常干净的pipe理方式与PM方法)涉及到保护整张纸(并保护它),同时有select地解锁允许的范围。 需要注意的是:所有的工作表单元必须在Workbook_Open
上完全locking。 这可以使用工作簿事件完成(如果您需要帮助,请询问)。
在下面分享的代码中,有几个项目需要注意。 rngAdmin
是指pipe理员应该访问的单元。 同样, rngProjectManager
引用PM应该访问的单元。 sSheetPassword
是实际表单密码,如Protect Sheet
Excelfunction中的设置。 另外两个密码只在我们的模块中。 显然,所有这些都应该变成更安全的东西。
如果inputpipe理员密码,则pipe理员范围将被解锁。 如果input了PM密码,则PM范围解锁。 如果input了不正确的密码,则表单是只读的。 思考?
Sub MultipleLayersofProtection() Dim rngAdmin As Range Dim rngProjectManager As Range Dim sUserEnteredPW As String Const sSheetPassword = "yupyupyup" Const sAdminPW As String = "ABC123" Const sProjectManagerPW As String = "LMNOP" Set rngAdmin = Sheet1.Range("A1:C50") Set rngProjectManager = Union(Sheet1.Range("A1:A5"), Sheet1.Range("C1:C5")) sUserEnteredPW = Application.InputBox("Please enter the password:", , , , , , , 2) Select Case sUserEnteredPW Case sAdminPW Sheet1.Unprotect Password:=sSheetPassword rngAdmin.Locked = False Sheet1.Protect Password:=sSheetPassword MsgBox ("Admin Access") Case sProjectManagerPW Sheet1.Unprotect Password:=sSheetPassword rngProjectManager.Locked = False Sheet1.Protect Password:=sSheetPassword MsgBox ("PM Access") Case Else MsgBox ("Read only access") End Select End Sub