Thread
:
VBA Code and Protection Sheet
View Single Post
#
7
Posted to microsoft.public.excel.programming
amirstal
external usenet poster
Posts: 35
VBA Code and Protection Sheet
Thanks very much!
Amir
wrote:
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.
Reply With Quote
amirstal
View Public Profile
Find all posts by amirstal