Use Macro to protect choosen sheets in workbook

K

kevhatch

I have a workbook with 10 sheets, 7 sheets used for Data entry (which I don't
want anyone to be able to change) and 3 for anybody to work with the data on
a day to day basis without them being able to corrupt the original. I know of
the Macro to protect the whole workbook but what I would like is to be able
to protect the 7 Data sheets and leave the 3 working sheets unlocked. Hope
this makes sense to you.
Thx in advance
 
D

Dave Peterson

Maybe something like:

Option Explicit
Sub testme()

Dim myPWD As String
Dim wks As Worksheet

myPWD = "TopSeCrET"

For Each wks In ActiveWorkbook.Worksheets
Select Case LCase(wks.Name)
'make sure you use lower case when you change these!
Case Is = "sheet1", "sheet2", "sheet5", "sheet99", _
"sheet100", "another sheet", "and one more", "lastone"
wks.Protect Password:=myPWD
Case Else
'do nothing
End Select
Next wks
End Sub
 
Top