vba - Multiple Permission Layers in Excel -


i'm working on project dashboard in excel, , need have 2 tiers of access: - layer 1: admin. o password protect cells users shouldn't touching. layer 2: project manager make ranges editable project managers have password specific sheet.

essentially want lock sheet have additional password unlock few cells on sheet.

is possible? i've looked around on here , google searches, have found nothing useful.

thanks time! joel

the easiest way started (and 1 cut , dry, admin vs. pm approach) involves protecting whole sheet (and keeping protected), yet unlocking permissible ranges selectively. caveat here: of sheet cells must locked on workbook_open. can done using workbook events (if need there, please ask).

in code i'm sharing below, there few items note. rngadmin refers cells admin should have access. likewise, rngprojectmanager refers cell pm should have access. ssheetpassword actual sheet password, setup in protect sheet excel feature. other 2 passwords reside in our module. obviously, of these should changed more secure.

if admin password entered, admin range unlocked. if pm password entered, pm range unlocked. if incorrect password entered, sheet read only. thoughts?

sub multiplelayersofprotection()     dim rngadmin range     dim rngprojectmanager range     dim suserenteredpw string      const ssheetpassword = "yupyupyup"     const sadminpw string = "abc123"     const sprojectmanagerpw string = "lmnop"       set rngadmin = sheet1.range("a1:c50")     set rngprojectmanager = union(sheet1.range("a1:a5"), sheet1.range("c1:c5"))      suserenteredpw = application.inputbox("please enter 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 access")     end select   end sub 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -