Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Password protection worksheet
I have a worksheet which I require to have password protected. I have set
the password up in the normal way no problem. I then want users to be able to run a macro to select a custom view, I have attached the following code to the macro which will allow the view to be run without requesting a password (if the bit with password isnt in there is does ask the user to input the password before showing the custom view). ' Sheets("sheet 2"). Unprotect Password = "mypassword" ActiveWorkbook.CustomViews("2 - Monday View").Show ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _ , AllowFormattingCells:=True, AllowFormattingColumns:=True, _ AllowFormattingRows:=True, AllowSorting:=True Range("L9").Select Sheets("sheet 2").Protect Password = "mypassword" End Sub However, whilst the macro appears to work it doesnt put the password back on the worksheet. The user can just go to unprotect sheet and click on ok which is what I need to stop. any help would be most welcome. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Password protection worksheet
Julie,
You need the correct syntax Sheets("sheet 2").Unprotect Password:="mypassword" Sheets("sheet 2").Protect Password:="mypassword" HTH, Bernie MS Excel MVP "julief" wrote in message ... I have a worksheet which I require to have password protected. I have set the password up in the normal way no problem. I then want users to be able to run a macro to select a custom view, I have attached the following code to the macro which will allow the view to be run without requesting a password (if the bit with password isnt in there is does ask the user to input the password before showing the custom view). ' Sheets("sheet 2"). Unprotect Password = "mypassword" ActiveWorkbook.CustomViews("2 - Monday View").Show ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _ , AllowFormattingCells:=True, AllowFormattingColumns:=True, _ AllowFormattingRows:=True, AllowSorting:=True Range("L9").Select Sheets("sheet 2").Protect Password = "mypassword" End Sub However, whilst the macro appears to work it doesnt put the password back on the worksheet. The user can just go to unprotect sheet and click on ok which is what I need to stop. any help would be most welcome. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel Worksheet Password Protection | Excel Worksheet Functions | |||
Worksheet level password protection | Excel Programming | |||
Password protection of worksheet when copied and pasted. | Excel Worksheet Functions | |||
Worksheet Password Protection in VBA | Excel Programming | |||
Setting worksheet protection password in VBA | Excel Programming |