Protecting Worksheets

  • Thread starter Thread starter biggrila06
  • Start date Start date
B

biggrila06

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?
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top