title: excel vba method workbook opened or closed true or false
body: <p>Is there a method or perhaps an object in conjunction with a <code>applicaton.</code> method which when utilized will write in the log (on a range on a sheet) whether the workbook was opened or closed.</p>
  
  <p>Instead of making two sub procedures, one log for opening and a log for closing, I am looking to combine both logs.</p>
  
  <pre><code>Option Explicit
  Private Sub workbook_open()
  
  Call Unprot
  Sheets("log").Activate
  Range("A1").Value = "Workbook Opened"
  Range("B1").Value = "User"
  Range("C1").Value = "LAN ID"
  Range("D1").Value = "Computer"
  Range("E1").Value = "Domain"
  Range("F1").Value = "Count"
  Rows("2:2").Insert
  Range("F2").Value = Sheets("log").Range("F2").Value + 1
  Range("A2").Value = Now
  Range("B2") = Application.UserName
  Range("C2") = Environ$("username")
  Range("D2") = Environ$("computername")
  Range("E2") = Environ$("USERDOMAIN")
      Cells.EntireColumn.AutoFit
  Call Prot
  
  End Sub
  
  Private Sub Workbook_BeforeClose(Cancel As Boolean)
   Call Unprot
  Sheets("log").Activate
  Range("H1").Value = "Workbook Closed"
  Range("I1").Value = "User"
  Range("J1").Value = "LAN ID"
  Range("K1").Value = "Computer"
  Range("L1").Value = "Domain"
  Range("M1").Value = "Count"
  Rows("2:2").Insert
  Range("M2").Value = Sheets("log").Range("M2").Value + 1
  Range("H2").Value = Now
  Range("I2") = Application.UserName
  Range("J2") = Environ$("username")
  Range("K2") = Environ$("computername")
  Range("L2") = Environ$("USERDOMAIN")
      Cells.EntireColumn.AutoFit
  Call Prot
  End Sub
  </code></pre>
  
  <p>P.S. I believe I could condense this code to a for loop?</p>