ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Protect Sheet > All sheets (https://www.excelbanter.com/excel-discussion-misc-queries/10787-protect-sheet-%3E-all-sheets.html)

Adam

Protect Sheet > All sheets
 
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
--
Adam
-----------
Windows 98 + Office Pro 97

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


"Adam" wrote in message
...
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
--
Adam
-----------
Windows 98 + Office Pro 97




tjtjjtjt

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


"Adam" wrote:

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
--
Adam
-----------
Windows 98 + Office Pro 97


Peo Sjoblom

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

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

"Adam" wrote:

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
--
Adam
-----------
Windows 98 + Office Pro 97



All times are GMT +1. The time now is 04:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com