VB - password protection

  • Thread starter Thread starter Karen
  • Start date Start date
K

Karen

Good morning
Sheet 1 is password protected and a button on that sheet tranfers data
to sheet 2 based on entries in a column.
I have used "Application.Dialogs(xlDialogProtectDocument).Show" to
prompt the user for the password however if they select the cancel
button the script still continues and transfers the data.
How can I stop it doing so if the cancel or even if an incorrect
password is entered?

Many Thanks
 
Hi Karen

No need to unprotect if the changes are taking place with VBA. Use some
code like

Sheet1.Protect Password:="Secret",UserInterFaceOnly:=True

No need to uptotect just adapt the above to suit.

However, if only those that know the password should be able to run the
code, use something like

Dim strResponse As String
strResponse = Application.Dialogs(xlDialogProtectDocument).Show
If strResponse = "False" Then Exit Sub

***** Posted via: http://www.ozgrid.com
Excel Templates, Training & Add-ins.
Free Excel Forum http://www.ozgrid.com/forum *****
 
Back
Top