Sheet Protection & Password

  • Thread starter Thread starter will07
  • Start date Start date
W

will07

Hello Everybody,

Is it possible to add some code to each worksheet that will enable me to
protect the worksheet and have a permanent password. At the moment, when you
unprotect the worksheet, you have to re-enter the password (twice) to protect
it again. I would like to be able to have the password in place all the time
so the user does not have to re-enter it again and again.

Thanks heaps
 
Something like:
Sub Unprotect()
ThisWorkbook.Worksheets("Report").Unprotect Password:="Password HERE"
ActiveSheet.Unprotect
End Sub

Sub Protect()
ThisWorkbook.Worksheets("Report").Protect Password:="Password HERE"
ActiveSheet.Protect
End Sub

You could add the codes to the WorkSheet_Change vent or similar to suit.


Corey...
 
I would use this code. This will protect or unprotect all your sheets. You
can call this code several ways.

1.) Setup a custom buttons in a toolbar and assign a macro to each one.
This way you just click a button in the toolbar and "Waaala" the worksheets
are protected.

2.) You can put the code in a Worksheet Event such as: Worksheet_Activate
and Worksheet_Deactivate. This will unprotect the worksheet when it is
selected and protect it when another sheet is selected.

3.) Put command buttons on the worksheet somewhere and assign these macros
to them.

I use #1.

Sub Protect()

Dim wks As Worksheet

For Each wks In Worksheets
wks.Protect Password:="password"
Next wks

End Sub

Sub UnProtect()

Dim wks As Worksheet

For Each wks In Worksheets
wks.UnProtect Password:="password"
Next wks

End Sub
 

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

Back
Top