ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Protecting Worksheets (https://www.excelbanter.com/excel-worksheet-functions/167759-protecting-worksheets.html)

biggrila06

Protecting Worksheets
 
Is there a way to protect and unprotect several worksheets, in the same
workbookat the same time? Or do you have to do each one individually?

Gaurav[_2_]

Protecting Worksheets
 
Right click on the first sheet tab, View Code, paste the following code
there.

Sub Protect_Selected_Sheets()
Set MySheets = ActiveWindow.SelectedSheets
For Each WS In MySheets
WS.Select
WS.Protect Password:="password"
Next WS
End Sub

Now Save and close

Now Right click on the second sheet tab, View Code, paste the following code
there.

Sub Protect_Selected_Sheets()
Set MySheets = ActiveWindow.SelectedSheets
For Each WS In MySheets
WS.Select
WS.Unprotect Password:="password"
Next WS
End Sub

Save and Close.

Now assign shortcut keys to the macros. for example to protect, CTRL+M and
to unprotect, CTRL+J.

Whenever you want to protect all the sheets, right click on any of the sheet
tabs, click on 'Select all sheets' and press CTRL+M. Same is to unprotect
just press CTRL+J.


"biggrila06" wrote in message
...
Is there a way to protect and unprotect several worksheets, in the same
workbookat the same time? Or do you have to do each one individually?





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

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