excel - Exit main sub procedure if called sub is false -
i have 'protection' sub procedure sub unprot_manually()
can been seen below. have sub procedure refereed main procedure of workbook. call protection procedure prior allowing user run main procedure. current code below, user able run main procedure regardless of entering correct password. need create 'protection' function, define boolean, , pass parameter main sub?
sub unprot_manually() dim password_input dim pass string application.screenupdating = false pass = "xxxxxx" password_input = application.inputbox("password", "awaiting user input..") if password_input = pass call unprot 'else 'msgbox ("incorrect, bye") 'msgbox ("incorrect") end if application.screenupdating = true end sub
change sub function, , check return value.
e.g. in main procedure,
if unprot_manually rest of program else msgbox "incorrect passowrd" end if
your other section become:
function unprot_manually() boolean 'set fail condition until success status unprot_manually=false ... if password_input = pass call unprot 'passed, set success condition unpot_manually=true end if ... end function
Comments
Post a Comment