Experts Exchange connects you with the people and services you need so you can get back to work.
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
The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.
Premium members get this course for $259.00.
Premium members get this course for $79.20.
Premium members get this course for $389.00.
Premium members get this course for $159.20.
Premium members get this course for $25.00.