Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Does Excel have a problem running a VBA code when the worksheet is
protected? If yes, is there a way to overcome it? Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() unlock the worksheet before running the code and lock it back up when you are done... Activesheet.Unprotect "<password" 'code here Activesheet.Protect "<password" amirstal wrote: Does Excel have a problem running a VBA code when the worksheet is protected? If yes, is there a way to overcome it? Thanks. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Should I put this at the top of the code (just below its name: Sub
EoDProcess())? "<password" - is where I should write the password that protects the sheet, right? Thanks. wrote: unlock the worksheet before running the code and lock it back up when you are done... Activesheet.Unprotect "<password" 'code here Activesheet.Protect "<password" amirstal wrote: Does Excel have a problem running a VBA code when the worksheet is protected? If yes, is there a way to overcome it? Thanks. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What you wrote is exactly what you should do...
Sub Test() ActiveSheet.Unprotect "password" 'your code here ActiveSheet.Protect "password" End Sub where 'password' is your sheet password when the sub is run, it will run through from beginning to end first unprotecting, running your code, then finally reprotecting the sheet. You can alternatively encompass a single line or any portion of code with the Unprotect/Protect code we have given you. Example: Sub Test() 'beginning of your code ActiveSheet.Unprotect "password" Msgbox "just a portion of your code" ActiveSheet.Protect "password" 'more of your code End Sub theSquirrel amirstal wrote: Should I put this at the top of the code (just below its name: Sub EoDProcess())? "<password" - is where I should write the password that protects the sheet, right? Thanks. wrote: unlock the worksheet before running the code and lock it back up when you are done... Activesheet.Unprotect "<password" 'code here Activesheet.Protect "<password" amirstal wrote: Does Excel have a problem running a VBA code when the worksheet is protected? If yes, is there a way to overcome it? Thanks. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
if you want to change cells´values, you have to unprotect them, yes. If you want to lock the sheet afterwards again, insert two rows in your code: Public Sub changingData ActiveWorkbook.Worksheets("ProtectedSheet").Unprot ect "password" ... (your code) ... ActiveWorkbook.("ProtectedSheet").Protect "password" End Sub Regards, Kai Cologne, Germany "amirstal" schrieb im Newsbeitrag oups.com... Does Excel have a problem running a VBA code when the worksheet is protected? If yes, is there a way to overcome it? Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sheet protection code conflicts with Pivot Table "auto refresh" | Excel Discussion (Misc queries) | |||
Sheet Protection and XLA code | Excel Programming | |||
Sheet Protection and VBA Code | Excel Discussion (Misc queries) | |||
disabling the "view code" tab - sheet protection? | Excel Programming | |||
protection sheet and code ??? | Excel Programming |