ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Protecting a workbook (https://www.excelbanter.com/excel-worksheet-functions/204046-protecting-workbook.html)

Kim

Protecting a workbook
 
Hi,
I have no problem protecting a worksheet with the 'Protect Sheet' option,
but is there anyway i can protect the whole workbook the same way, without
having to select each sheet individually?
Thanks in advanced!


Otto Moehrbach[_2_]

Protecting a workbook
 
Kim
When you click on Tools - Protection, you have the option of protecting
the whole workbook. HTH Otto
"Kim" wrote in message
...
Hi,
I have no problem protecting a worksheet with the 'Protect Sheet' option,
but is there anyway i can protect the whole workbook the same way, without
having to select each sheet individually?
Thanks in advanced!




Spiky

Protecting a workbook
 
You may wish to note, Kim, that Protect Workbook does different things
than Protect Sheet. If you are wanting to protect many sheets at a
time, you'll need a macro.

tech1NJ

Protecting a workbook
 
Hi Kim,

You can create a macro to take care of this. As part of the Macro, you will
create a Form with a Command Button. You can then add the code to the
Commnand button as follows.

Private Sub CommandButton1_Click()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
If wSheet.ProtectContents = True Then

wSheet.Unprotect Password:=TextBox1.Text
Else
wSheet.Protect Password:="replace this text with password you wish
to open sheets with"
End If
Next wSheet
Unload Me
End Sub
--
tech1NJ


"Kim" wrote:

Hi,
I have no problem protecting a worksheet with the 'Protect Sheet' option,
but is there anyway i can protect the whole workbook the same way, without
having to select each sheet individually?
Thanks in advanced!


Gord Dibben

Protecting a workbook
 
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

Unprotect all sheets....................

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

Protect selected sheets..........................

Sub Protect_Selected_Sheets()
Application.ScreenUpdating = False
Set MySheets = ActiveWindow.SelectedSheets
For Each ws In MySheets
ws.Select
ws.Protect Password:="justme"
Next ws
Application.ScreenUpdating = True
End Sub

Unprotect selected sheets................

Sub UnProtect_Selected_Sheets()
Application.ScreenUpdating = False
Set MySheets = ActiveWindow.SelectedSheets
For Each ws In MySheets
ws.Select
ws.UnProtect Password:="justme"
Next ws
Application.ScreenUpdating = True
End Sub


Gord Dibben MS Excel MVP

On Thu, 25 Sep 2008 16:39:01 -0700, Kim
wrote:

Hi,
I have no problem protecting a worksheet with the 'Protect Sheet' option,
but is there anyway i can protect the whole workbook the same way, without
having to select each sheet individually?
Thanks in advanced!



tech1NJ

Protecting a workbook
 
Hi Kim,

Did you find my post useful? Please let me know. I like to make sure that
you got what you needed. If so, please let me know by indicating so on the
reply or the post itself. Thanks
--
tech1NJ


"Kim" wrote:

Hi,
I have no problem protecting a worksheet with the 'Protect Sheet' option,
but is there anyway i can protect the whole workbook the same way, without
having to select each sheet individually?
Thanks in advanced!



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

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