I have been asked to create VBA code to help a user to password protect all sheets in a workbook less the Summary sheet. The workbook sometimes has 20 sheets and other times 45 sheets.
I have the following code which will allow me to protect all sheets but how do I exclude the Summary sheet. I am suggesting a range of cells are left unprotected so my users can edit them. So in my code I need to add the password and make sure the Summary sheet isn't included.
I have the following code which will allow me to protect all sheets but how do I exclude the Summary sheet. I am suggesting a range of cells are left unprotected so my users can edit them. So in my code I need to add the password and make sure the Summary sheet isn't included.
Sub mcrProtect3()
Dim i As Integer
' Loop through all sheets in the workbook.
For i = 1 To Sheets.Count
With Sheets(i)
.Range("D4:K26").Locked = False
.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End With
Next i
End Sub