ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   MS Excel (https://www.excelbanter.com/excel-worksheet-functions/135556-ms-excel.html)

Garg Swadesh

MS Excel
 
Can we protact two or more sheets simultaneously using one password.
Similarly can we unprotect two or more sheets in single command having one
password.

macropod

MS Excel
 
Hi Garg Swadesh,

No, they have to be done one at a time, but you could use a macro to automate the processes, thus requiring the user to input the
password only once. For example, the following 'ProtectAllSheets' code protects all unprotected sheets, while the
'UnprotectAllSheets' code does the opposite:

Sub ProtectAllSheets()
Dim wkSheet As Worksheet
For Each wkSheet In ActiveWorkbook.Worksheets
If wkSheet.ProtectContents < True Then
wkSheet.Protect Password:=InputBox("Please enter the password")
End If
Next wkSheet
End Sub

Sub UnprotectAllSheets()
Dim wkSheet As Worksheet
For Each wkSheet In ActiveWorkbook.Worksheets
If wkSheet.ProtectContents = True Then
wkSheet.Unprotect Password:=InputBox("Please enter the password")
End If
Next wkSheet
End Sub


Cheers

--
macropod
[MVP - Microsoft Word]
-------------------------

"Garg Swadesh" <Garg wrote in message ...
Can we protact two or more sheets simultaneously using one password.
Similarly can we unprotect two or more sheets in single command having one
password.



Don Guillett

MS Excel
 

use a looping macro to do either

--
Don Guillett
SalesAid Software

"Garg Swadesh" <Garg
wrote in message
...
Can we protact two or more sheets simultaneously using one password.
Similarly can we unprotect two or more sheets in single command having one
password.





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

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