ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Protect/unprotect ALL worksheets in workbook ? (https://www.excelbanter.com/excel-discussion-misc-queries/80360-protect-unprotect-all-worksheets-workbook.html)

Newsgal

Protect/unprotect ALL worksheets in workbook ?
 

-- Is it possible to protect/unprotect all worksheets in a workbook at once
instead of having to do each individually if the password is the same?

News Gal

Chip Pearson

Protect/unprotect ALL worksheets in workbook ?
 
The only way to do that is with some VBA code:

Sub ProtectAll()
Dim WS As Worksheet
For Each WS In ActiveWorkbook.Worksheets
WS.Protect Password:="whatever"
Next WS
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Newsgal" wrote in message
...

-- Is it possible to protect/unprotect all worksheets in a
workbook at once
instead of having to do each individually if the password is
the same?

News Gal




Ron de Bruin

Protect/unprotect ALL worksheets in workbook ?
 
The only way is to use a macro to do this

Sub test()
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
sh.Unprotect "ron"
Next sh
End Sub

Or
sh.Protect "ron"



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Newsgal" wrote in message ...

-- Is it possible to protect/unprotect all worksheets in a workbook at once
instead of having to do each individually if the password is the same?

News Gal




Kevin B

Protect/unprotect ALL worksheets in workbook ?
 
This macro would do the trick

Sub Unprotect()

Dim wb As Workbook
Dim ws As Worksheet
Dim blnIsProtected As Boolean
Set wb = ActiveWorkbook

For Each ws In wb.Worksheets
ws.Unprotect "test"
Next ws

Set wb = Nothing
Set ws = Nothing

End Sub

--
Kevin Backmann


"Newsgal" wrote:


-- Is it possible to protect/unprotect all worksheets in a workbook at once
instead of having to do each individually if the password is the same?

News Gal


ers18

Protect/unprotect ALL worksheets in workbook ?
 
I need to know how to protect the entire worksheet (all tabs within it) with
a click of a button; not sure what the last solution entails. Please help.

ers



Gord Dibben

Protect/unprotect ALL worksheets in 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

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


Gord Dibben MS Excel MVP

On Tue, 4 May 2010 10:11:01 -0700, ers18
wrote:

I need to know how to protect the entire worksheet (all tabs within it) with
a click of a button; not sure what the last solution entails. Please help.

ers




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

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