title: Code to systematically lock excel sheets, only working on 1 spreadsheet (VB)
body: <p>I'm basically trying to lock all but one sheet systematically (password driven) in excel. I've developed the following code, however, it only seems to be locking 1 sheet (Dec) of the many sheets. Any help would be HUGELY appreciated. Thanks!</p>
  
  <pre><code>Private Sub Workbook_BeforeClose(Cancel As Boolean)
   Dim ws As Worksheet
   Dim strPassWord As String
   strPassWord = "apple"
  
   Sheets("Jan").Select
   Sheets("Feb").Select
   Sheets("Mar").Select
   Sheets("April").Select
   Sheets("May").Select
   Sheets("June").Select
   Sheets("July").Select
   Sheets("Aug").Select
   Sheets("Sept").Select
   Sheets("Oct").Select
   Sheets("Nov").Select
   Sheets("Dec").Select
   ActiveSheet.Protect Password:=strPassWord, DrawingObjects:=True, Contents:=True, Scenarios:=True
   ActiveSheet.EnableSelection = xlNoSelection
  
  End Sub
  
  Private Sub Workbook_Open()
   Dim ws As Worksheet
   Dim strPassWord As String
   strPassWord = InputBox(Prompt:="Password", _
    Title:="Enter Password", Default:="User Password")
  
   If strPassWord = "apple" Then
  
    Sheets("Jan").Select
    Sheets("Feb").Select
    Sheets("Mar").Select
    Sheets("April").Select
    Sheets("May").Select
    Sheets("June").Select
    Sheets("July").Select
    Sheets("Aug").Select
    Sheets("Sept").Select
    Sheets("Oct").Select
    Sheets("Nov").Select
    Sheets("Dec").Select
    ActiveSheet.Unprotect Password:=strPassWord
   Else
    MsgBox ("Password Incorrect")
   End If
  End Sub
  </code></pre>