Excel Macro; Adding Password [Solved/Closed]

Report
Posts
10
Registration date
Monday July 28, 2008
Status
Member
Last seen
August 8, 2008
-
 Pujdo -
Hello,

Hope you anyone can help me with this...

I need to create a macro that unlocks a password-protected sheet with password "password", do some instruction, then locks it again with same password.

Thanks in advance for any assistance.

zero

5 replies

Posts
433
Registration date
Saturday February 16, 2008
Status
Member
Last seen
October 17, 2008
109
Hello zero,
the syntax is quite simple
ActiveSheet.Unprotect ("MyPassWord")
'instructions
ActiveSheet.Protect ("MyPassWord")

for more details, I suggest you type "worksheet.protect" and "worksheet.unprotect" in the help file of visual basic editor.
Ivan
13
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2778 users have said thank you to us this month

Posts
10
Registration date
Monday July 28, 2008
Status
Member
Last seen
August 8, 2008

Hi Ivan,

Thanks for this, and other one as well.
I'm not actually a programer. I self-studied excel and i'm good at using formulas.
I just recently learn about macro and I used to just for recording to eliminate the circular ref error with formulas.
I was glad to have found this site and have read one of your response.

Thanks,

Anton
The ActiveSheet.Protect ("MyPassWord") works, but what if you want the set certain "abilities" to True when assigning the password as in the following code.

ActiveSheet.Protect ("MyPassWord") DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True

This errors out when the Macro is ran. Is there a different Syntax for a case like this?
Posts
433
Registration date
Saturday February 16, 2008
Status
Member
Last seen
October 17, 2008
109 > DaveyBoy
Hello,
try this syntax :
ActiveSheet.Protect PassWord:="MyPassWord", DrawingObjects:=True,  _ 
Contents:=True,  Scenarios:=True, AllowSorting:=True, AllowFiltering:=True,  _ 
AllowUsingPivotTables:=True 

Ivan
>
Posts
433
Registration date
Saturday February 16, 2008
Status
Member
Last seen
October 17, 2008

Hey Ivan valuable info on your post. Thanks pal.
thanks Ivan...ur post was a real help :)
Posts
10
Registration date
Monday July 28, 2008
Status
Member
Last seen
August 8, 2008

Thanks Ivan.

How do I change the status of this topic to "resolved"?

Anton
Posts
7073
Registration date
Saturday April 7, 2007
Status
Moderator
Last seen
June 24, 2020
498
Hi,
Go to the top of your thread (to the right part), and check the case "solved" after click on "OK"
Best regards
Thanks Ivan!
i want those number in front add ''0" (Zero) how to 456789
11111
22222
33333
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
760
Ram: what this question "i want those number in front add ''0" (Zero) how to 456789 11111 22222 33333", has to do with the thread ?
how to remove the xsl sheet password
Tnx for this :) this is working for me :)