Const myPassword = "password"
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim wkb As Workbook
Dim wks As Worksheet
Set wkb = ThisWorkbook
For Each wks In wkb.Worksheets
Select Case UCase(wks.Name):
Case "1-20 LABELS", "BLANK LABELS": 'exclude those in this list - put ALL IN UPPER CASE = CHECK SPACES AND SPELLING!!!
'do nothing to these sheets
Case "LABOR", "ROSTER", "CONVERTER", "INPUT 1-20", "INPUT 21-40": 'one sheet name per quotation marks
'put any different worksheet protection code, here
wks.Protect Password:=myPassword, AllowFiltering:=True
Case "finallyOne more sheet", "other sheet", "that get the same protection": 'one sheet name per quotation marks
'for future use, if you want different type of protection
'put any different (from the above) worksheet protection code, here
Case Else: 'all others, just do this protect approach
wks.Protect DrawingObjects:=False, Contents:=True, Scenarios:=False, AllowFormattingCells:=True
Open in new window
IT issues often require a personalized solution. With Ask the Experts™, submit your questions to our certified professionals and receive unlimited, customized solutions that work for you.
Take hold of your future.