title: macro run-time error '9': subscript out of range
body: <p>I found a macro on the web to protect a worksheet with a password.  It works fine, but when I save the file I get the message:  run-time error '9': subscription out of range.  I have never programmed or used visual basic before and could use some help .  Thank you</p>
  
  <p>The macro is:</p>
  
  <pre><code>Private Sub Workbook_BeforeClose(Cancel As Boolean)
  
  'Step 1:Protect the sheet with a password
      Sheets("Sheet1").protect Password:="btfd"
  
  'Step 2: Save the workbook
      ActiveWorkbook.Save
  End Sub
  </code></pre>