View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default Password protect select sheets in a workbook

How is the macro supposed to know which sheets you want to protect. Is there
any kind of a flag or pattern to look for that defines whether the sheet
needs to be protected???
--
HTH...

Jim Thomlinson


"Needhelp" wrote:

Thanks, I should have been more clear. some of the worksheets that I want to
protect do not have menu in the name
"Jim Thomlinson" wrote:

Sub ProtectSheets()
Dim mySheet As Worksheet
For Each mySheet In Worksheets
if left(mySheet.name, 4) = "Menu" then _
mySheet.protect "Password", True, True, True
Next mySheet
End Sub
--
HTH...

Jim Thomlinson


"Needhelp" wrote:

The macro below protects all worksheets in my workbook. I only want to
protect specific worksheets with the names Menu1, Menu2, etc. How would i
modify the macro to accomplish this. I know I can just select each worksheet
and protect it but I would like to learn the more advanced version below.
Sub ProtectSheets()
Dim mySheet As Worksheet
For Each mySheet In Worksheets
mySheet.Select
mySheet.protect "Password", True, True, True
Next mySheet
End Sub