Using an Input Box to Unprotect a Worksheet

  • Thread starter Thread starter Pablo
  • Start date Start date
P

Pablo

I have what is probably an easy question but I cannot seem to come up with a
solution. I have a worksheet that I am protecting various columns with a
password. On the worksheet I have a button with a macro attached to it. I
would like to have an InputBox appear requesting a password that will
unprotect the worksheet when the button is clicked.

All help is greatly appreciated.

Thanks.
 
Pablo,

This utilises an inputbox so there is no password mask and it can be read by
anyone looking. You can have a masked input box but that is more complicated
or you can use a userform to look like an input box and have a password mask
in that

Sub Button1_Click()
response = InputBox("Enter Password")
On Error GoTo GetMeOut
ActiveSheet.Unprotect Password:=response
'your code



Exit Sub
GetMeOut:
MsgBox "Incorrect password supplied"
End Sub

Mike
 
Thank you very much.

Mike H said:
Pablo,

This utilises an inputbox so there is no password mask and it can be read by
anyone looking. You can have a masked input box but that is more complicated
or you can use a userform to look like an input box and have a password mask
in that

Sub Button1_Click()
response = InputBox("Enter Password")
On Error GoTo GetMeOut
ActiveSheet.Unprotect Password:=response
'your code



Exit Sub
GetMeOut:
MsgBox "Incorrect password supplied"
End Sub

Mike
 
Back
Top