Protecting Multiple Sheets

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have a workbook with 60 sheets in it. I need to protect 52 sheets only.

Is there a way I can do this collectively instead of each one individaully??

Cheers
 
Hi

one way is to run the following code:
---
Sub ProtectAll()
For Each ws In Sheets
ws.Protect ("pwd")
Next

Set sh = ActiveSheet
varr = Array("Sheet1", "sheet3")
For i = LBound(varr) To UBound(varr)
With Worksheets(varr(i))
.Activate
.Unprotect ("pwd")
End With
Next
sh.Activate
End Sub
--
in the line
varr = Array("Sheet1", "sheet3")
list the names of the sheets you do not want protected.

note: this code applies a password of pwd to the protected sheets - if you
want another password just replace pwd (in 2 places) with the password you
want, if you don't want a password just delete the ("pwd") bit.

to use this code, right mouse click on any sheet tab, choose view code, to
display the vbe window, choose insert / module, copy & paste the code in
there, make the changes and then use ALT & F11 to switch back to your
workbook. Choose tools / macro / macros, find Protect all and choose RUN
 

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

Similar Threads

Excel Move or Copy Stopped Working? 0
protecting sheets 2
password protection 7
links 1
Excel shortcut options 0
Must I use IRM to protect an entire workbook? 1
Merge Multiple workbook sheets into one workbook 0
Excel Protection 2

Back
Top