Protect Sheet > All sheets

G

Guest

Hi

I'm using Excel 97 and get a bit annoyed having to Protect each worksheet
individually.

Is there a way where I can password protect all sheets in a workbook?

Please advise
 
J

JulieD

Hi Adam

only by using code such as:

Sub ProtectAll()
For each ws in sheets
ws.protect("pwd")
Next
End Sub

'and to unprotect

Sub UnprotectAll()
For each ws in sheets
ws.unprotect("pwd")
Next
End Sub
----
Please post back if you'ld like assistance using this code. Note - you'll
need to change pwd to your actual password.

Cheers
JulieD
 
G

Guest

You have to use VBA for this. This example willl assign the same password to
each sheet.
I'm running 2003, and this works for me.

If you are unfamiliar with macors, see:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Sub ProtectAllSheets()
Dim sht As Worksheet
For Each sht In ThisWorkbook.Worksheets
sht.Protect "password"
Next sht
End Sub

tj
 
G

Guest

Only through a macro, put these 2 macros in a module (Alt + F11, insert>module)

Sub ProtectMe()
Dim sh As Worksheet
Application.ScreenUpdating = False
For Each sh In ThisWorkbook.Worksheets
sh.Protect "xxxxx"
Next sh
Application.ScreenUpdating = True
End Sub

Sub UnProtectMe()
Dim sh As Worksheet
Application.ScreenUpdating = False
For Each sh In ThisWorkbook.Worksheets
sh.Unprotect "xxxxx"
Next sh
Application.ScreenUpdating = True
End Sub


replace "xxxxx" with whatever password you want to use
press Alt + q to close the VBE and save the workbook.
To run the macros press Alt + F8

Regards,

Peo Sjoblom
 

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