Macro to Unprotect sheet!?

N

Neo1

Hello I'm quite stuck, I'm trying to create a macro while the worksheet
is protected and the thing is i click unprotect and the password
dialogue box appears asking me to enter password which is fine, but can
i create a macro so that when it is played it opens this dialogue box
for me to enter password to unprotect sheet?

Thanks a lot
From John
 
S

swatsp0p

try this:


Code:
--------------------
Sub Unprotect sheet()
'Private Sub CommandButton1_Click()

' unprotect Macro

ActiveSheet.unprotect

End Sub
--------------------


If you want to assign this to a button, uncomment the Private Sub line
and comment out (or remove) the Sub line.

HTH

Bruce
 
N

Neo1

I dont understand ...what do you mean?

do i need to use VB code for it?

Thanks a lot
From John
 
N

Neo1

Any help to create a macro to unprotect worksheet but before it does to
pop up the dialogue box asking user to enter password to unprotect
worksheet?

I need help pleasee
Thanks a lot
From John
 
D

Desert Piranha

Neo1 said:
Any help to create a macro to unprotect worksheet but before it does to
pop up the dialogue box asking user to enter password to unprotect
worksheet?

I need help pleasee
Thanks a lot
From JohnHi Neo1,

It sounds like you want the sheet to automaticaly unprotect with a
password.
If this is so, Just add to Bruce's code for the password.

Put this in the Module for the sheet in question.
Right Click on the worksheet tab and select "View Code".
Paste the folowing code there. Don't forget to replace your password
where it says "your password goes here"

Private Sub Worksheet_Activate()
ActiveSheet.Unprotect Password:=your password goes here
End Sub

Same thing without a password:

Private Sub Worksheet_Activate()
ActiveSheet.Unprotect
End Sub
 
N

Neo1

yeah ok thanks...but how do i apply it to a button so that whenever i
need to click the unprotect button for the sheet....

and also how can i make it so that each worksheet has a different
password to unprotect it?

Thanks a lot
From John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top