ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Protect cells function (https://www.excelbanter.com/excel-programming/323456-protect-cells-function.html)

Bhupinder Rayat

Protect cells function
 
I have the following code that unprotects a sheet and a workbook.

On Error GoTo errorHandler
ActiveSheet.Unprotect 'Unprotects the
sheet: Menu
ActiveWorkbook.Unprotect (123) 'Unprotects the
workbook Sheets("InternalMenu").Visible = True 'Unhides
sheet: Internal Menu
Sheets("JobSheet").Visible = True

Exit Sub
On Error GoTo 0
errorHandler:
MsgBox "The Password you have supplied is incorrect. Please verify that you
have the correct capitilistation."

The trouble is that when you are prompted for the password to unprotect the
sheet, if you press cancel, the code still runs.

How can I manage the cancel button on the Password prompt box to actually
exit the sub when cancel is pressed.

I have tried if unprotect = vbCancel then exit sub, and varaiations of this,
but to no envail.

Can anyone help?

Thanks,

Pinda


Patrick

Protect cells function
 
Where are you prompting for the password? Seems like there is some code
missing here.

Bhupinder Rayat

Protect cells function
 
Hi,

ActiveSheet.Unprotect prompts the password, since no password is entered in
brackets.

Can anyone help?

Bhupinder.

"Patrick" wrote:

Where are you prompting for the password? Seems like there is some code
missing here.



All times are GMT +1. The time now is 03:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com