Protect multiple worksheets excel 2007

Jworley2

New Member
Joined
May 9, 2008
Messages
14
When I select multiple worksheets in excel 2007 the protect worksheet button is greyed out. How do I protect multiple worksheets in excel 2007 without having to do each one individually.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Welcome to the Board!

You can use VBA:

<font face=Calibri><SPAN style="color:#00007F">Public</SPAN> ws <SPAN style="color:#00007F">As</SPAN> Worksheet<br><br><SPAN style="color:#00007F">Sub</SPAN> ProtectAll()<br>    <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> ws <SPAN style="color:#00007F">In</SPAN> ActiveWorkbook.Worksheets<br>        ws.Protect<br>    <SPAN style="color:#00007F">Next</SPAN> ws<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br><br><SPAN style="color:#00007F">Sub</SPAN> UnProtectAll()<br>    <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> ws <SPAN style="color:#00007F">In</SPAN> ActiveWorkbook.Worksheets<br>        ws.Unprotect<br>    <SPAN style="color:#00007F">Next</SPAN> ws<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Hope that helps,
 
Upvote 0
Code:
 Public Sub ProtectGroupedSheets()
'========================================================================
' THIS PROTECTS GROUPED SHEETS
'========================================================================
'Const csPASSWD As String = "password"
        Dim MySheets As Sheets
        Dim actSheet As Worksheet
        Dim wkSht As Worksheet
        Set actSheet = ActiveSheet
        Set MySheets = ActiveWindow.SelectedSheets
        actSheet.Select
        For Each wkSht In MySheets
            wkSht.Protect 'Password:=csPASSWD ' Can also use Unprotect
        Next wkSht
        actSheet.Select
        MySheets.Select False
    End Sub

Another option, if you need to protect specific sheets only.

Not sure if this will meet your needs.

Select the specific sheets you want to protect then run the code. You can put password protection in if required

Mark:)
 
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,144
Members
448,552
Latest member
WORKINGWITHNOLEADER

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top