Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Is it possible to protect/unprotect a sheet with a password in VBA?. Example please if any. Thanks PeteD |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Pete,
Here is a sample that I use. At the start of the code I unprotect the sheets so the rest of my code can run: Sheets("Raw Data").Select ActiveSheet.Unprotect Password:="yourpassword" Sheets("Output Page").Select ActiveSheet.Unprotect Password:="yourpassword" Then I password protect the sheets again: Sheets("Raw Data").Select ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="yourpassword" Sheets("Output Page").Select ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="yourpassword" Make sure you also password protect the code. jill -----Original Message----- Hi, Is it possible to protect/unprotect a sheet with a password in VBA?. Example please if any. Thanks PeteD . |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yes you can. Here is sample code. This uses the active
sheet but you can do a select of any sheet also. Sub ProtectWorksheet() ActiveSheet.Protect password:="password" End Sub Sub UnprotectWorksheet() ActiveSheet.Unprotect password:="password" End Sub -----Original Message----- Hi, Is it possible to protect/unprotect a sheet with a password in VBA?. Example please if any. Thanks PeteD . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Jill
PeteD -----Original Message----- Pete, Here is a sample that I use. At the start of the code I unprotect the sheets so the rest of my code can run: Sheets("Raw Data").Select ActiveSheet.Unprotect Password:="yourpassword" Sheets("Output Page").Select ActiveSheet.Unprotect Password:="yourpassword" Then I password protect the sheets again: Sheets("Raw Data").Select ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="yourpassword" Sheets("Output Page").Select ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="yourpassword" Make sure you also password protect the code. jill -----Original Message----- Hi, Is it possible to protect/unprotect a sheet with a password in VBA?. Example please if any. Thanks PeteD . . |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Tim.
Pete -----Original Message----- Yes you can. Here is sample code. This uses the active sheet but you can do a select of any sheet also. Sub ProtectWorksheet() ActiveSheet.Protect password:="password" End Sub Sub UnprotectWorksheet() ActiveSheet.Unprotect password:="password" End Sub -----Original Message----- Hi, Is it possible to protect/unprotect a sheet with a password in VBA?. Example please if any. Thanks PeteD . . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Protecting Sheets | Excel Worksheet Functions | |||
protecting sheets | Excel Discussion (Misc queries) | |||
Protecting Sheets | Excel Worksheet Functions | |||
Protecting Sheets | Excel Discussion (Misc queries) | |||
Protecting sheets | Excel Discussion (Misc queries) |