excel - Password protect without unprotecting -


i have workbook distributed multiple departments. each department has own sheet within workbook, have input notes in cells. i've password protected each sheet except cells they'll inputting notes (lots of formulas referencing other sheets, can't touched except me). on top of password protection, added vba code prompts user password before can add notes (to discourage other departments inputting notes wrong sheet.) each department has own password sheet. problem is, code unprotects entire sheet when correct departmental password entered, exposing locked cells other users. need code prompt user when sheet selected, , when password enetered correctly, unprotect unlocked cells. have far:

sub worksheet_activate()     const passwrd string = "abc123"     dim sinput variant     dim attempt integer     me.protect password:=passwrd     attempt = 1         sinput = inputbox("please enter password sheet", "password    required    attempt:" & attempt)         if strptr(sinput) = 0         'cancel pressed             exit         elseif sinput = passwrd    ' valid password             me.unprotect password:=passwrd             exit         else             msgbox "invalid password", 48, "invalid"             attempt = attempt + 1         end if     loop until attempt > 3    ' "don't let inputbox close if password not correct  end sub 


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -