excel - Protect one worksheet with a password from showing up -
is there built-in way in excel protect 1 spreadsheet in workbook password?
something when user ticks or selects control , password prompted before worksheet become visible.
if not built excel, can implemented vba?
you try approach which:
- makes sheet
veryhidden,protectedcan't unprotected - or detected - standard xl menus - adds in protection on
workbook_beforeclose,workbook_openevents - i haved used sheet called yoursheet example
- you should protect vba in project add further security.
insert active x checkbox , use code check if:
- the checkbox true
- the user knows password
unhidesheet. (fred used in example)
checkbox code
private sub checkbox1_click() dim strpass string if checkbox1.value strpass = application.inputbox("please enter password", "admin check") if strpass = "fred" thisworkbook.sheets("yoursheet") .unprotect "fred" .visible = xlsheetvisible msgbox "sheet unhidden!", vbinformation end else msgbox "wrong password", vbcritical end if end if end sub the thisworkbook module
private sub workbook_beforeclose(cancel boolean) thisworkbook.sheets("yoursheet") .protect "fred" .visible = xlveryhidden end end sub private sub workbook_open() thisworkbook.sheets("yoursheet") .protect "fred" .visible = xlveryhidden end end sub
Comments
Post a Comment