Protection on Multiple Sheets

  • Thread starter Thread starter Sophie
  • Start date Start date
S

Sophie

I have several sheets in one workbook that i want to protect all with the
same password. I tried some of the codes that were given but they did not
work for me. Can some one please help? Also if you can explain it thouroughly
for me as I am still learning this whole new macro thing.

In advance thanks

-Sofia
 
I used the following code:

Sub ProtectAllSheets()
Application.ScreenUpdating = False
Dim N As Single
For N = 1 To Sheets.Count
Sheets(N).Protect Password:="justme"
Next N
Application.ScreenUpdating = True
End Sub


I did the following:

Copied and pasted it into the VBA and ran the macro and saved changes but
then what do I do? How do I get it to unprotect?

Sub UnprotectAllSheets()
Application.ScreenUpdating = False
Dim N As Single
For N = 1 To Sheets.Count
Sheets(N).Unprotect Password:="justme"
Next N
Application.ScreenUpdating = True
End Sub

Sub Protect_Selected_Sheets()
Set MySheets = ActiveWindow.SelectedSheets
For Each ws In MySheets
ws.Select
ws.Protect Password:="justme"
Next ws
End Sub
 
If you hit alt-F8, you should see a list of macros available to you.

Select the "UnprotectAllSheets" macro and click Run.

If the list doesn't include these macros, then make sure you put the code into
the correct location.

If the macro starts, then stops with an error message, you'll have to share how
it broke--what line caused the trouble.

If you're new to macros:

Debra Dalgleish has some notes how to implement macros here:
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)
 
Ok this was too time consuming. I just need a code to put to protect all the
worksheets and then unprotect them when needed. Can you supply me with that?



Thanks,
 
You have the code.

I don't think I could make any meaningful changes to what you have.
 
When I put unprotect all it gives me an error and to fix it.

Gord can you help??? You always help me with my absurd questions. Can you
provide me with a code that will work and walk me through the process to put
this in place?

Thanks,
 
You posted three macros, all of which should work.

1. Protect all sheets

2. Unprotect all sheets

3. Protect selected sheets.

All three of these should be stored in a General module in your workbook.

If you used 1 to protect all sheets there is no reason that 2 will not
unprotect all sheets.

I will not provide any different macros. You should be able to figure out
how to create a fourth macro to unprotect selected sheets if you need one.

Please post the line where you get the error on the macro UnprotectAllSheets


Gord
 
Back
Top