Excel Worksheet protection

B

BillFitz

Is there a simple way to Protect/Unprotect individual worksheets in a file
without having to visit each worksheet.
I use a file containing 31 worksheets for each day of month and I can make
changes each month, to update for new product lines on each sheet, across all
worksheets using the Group function. However, in order to Unprotect and then
Protect each worksheet individually is a time consuming process.
 
B

BillFitz

I tried that, including the input of a Password, but found that the Password
was not correctly applied, with the result that the Unprotect worked without
using a Password
 
G

Gord Dibben

Bill

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

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


Gord Dibben MS Excel MVP
 

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

Top