title: BeforeClose VBA Event Closing Workbook When Cancel = True
body: <p>I'm trying to write a short macro that will prevent the user of an excel workbook from closing the workbook without protecting the first sheet.  </p>
  
  <p>The code shows the message box but then proceeds to close the workbook.  From my understanding, if the "Cancel" parameter is set to True, the workbook shouldn't close.  </p>
  
  <pre><code>Private Sub Workbook_BeforeClose(Cancel As Boolean)
  
      If Sheets(1).ProtectContents = True Then
          Cancel = False
      Else
          MsgBox "Please Protect 'Unique Futures' Worksheet Before Closing Workbook"
          Cancel = True
      End If    
  End Sub
  </code></pre>
  
  <p>I just need the code to display the message box and then not close if the first sheet is not protected.</p>