ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Protecting more than one worksheet at a time (https://www.excelbanter.com/excel-discussion-misc-queries/207517-protecting-more-than-one-worksheet-time.html)

Donnah

Protecting more than one worksheet at a time
 
Is there any way to protect more than one worksheet at a time without have to
right click on each worksheets tab and choose 'Protect Sheet'?



Don Guillett

Protecting more than one worksheet at a time
 
sub protectemall()
for each ws in worksheets
ws.protect
next ws
end sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Donnah" wrote in message
...
Is there any way to protect more than one worksheet at a time without have
to
right click on each worksheets tab and choose 'Protect Sheet'?




Jim Thomlinson

Protecting more than one worksheet at a time
 
Nothing built in but you can do it with a fairly simple macro. I have created
an addin for myself with the code in it to make it easy to do...

Public Sub ProtectAll()
Dim wks As Worksheet
Dim wksAll As Sheets

Application.ScreenUpdating = False
If ActiveWindow.SelectedSheets.Count 1 Then
Set wksAll = ActiveWindow.SelectedSheets
Else
Set wksAll = ActiveWorkbook.Worksheets
End If
On Error Resume Next
For Each wks In wksAll
Select Case Trim(wks.Name)
Case "Start" 'excluded sheet
Case "Main" 'excluded sheet
Case Else
wks.Protect "MyPassword"
End Select
Next wks
Application.ScreenUpdating = True
End Sub
--
HTH...

Jim Thomlinson


"Donnah" wrote:

Is there any way to protect more than one worksheet at a time without have to
right click on each worksheets tab and choose 'Protect Sheet'?




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

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