Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim LastRow As Long
LastRow = shLog.[A65536].End(xlUp).Row
If LastRow = 1 Then
shLog.Cells(LastRow, 1) = "User"
shLog.Cells(LastRow, 2) = "Log On Date/Time"
shLog.Cells(LastRow, 3) = "Log Off Date/Time"
shLog.[A1:C1].Font.Bold = True
shLog.Cells(LastRow + 1, 1) = Application.UserName
shLog.Cells(LastRow + 1, 2) = Format(Now, "mmmm d, yyyy h:mm AM/PM")
shLog.Cells(LastRow + 1, 3) = Format(Now, "mmmm d, yyyy h:mm AM/PM")
Else
shLog.Cells(LastRow, 3) = Format(Now, "mmmm d, yyyy h:mm AM/PM")
End If
ThisWorkbook.Save
End Sub
Private Sub Workbook_Open()
Dim NextRow As Long
NextRow = shLog.[A65536].End(xlUp).Offset(1, 0).Row
If NextRow = 1 Then
shLog.Cells(NextRow, 1) = "User"
shLog.Cells(NextRow, 2) = "Log On Date/Time"
shLog.Cells(NextRow, 3) = "Log Off Date/Time"
shLog.[A1:C1].Font.Bold = True
shLog.Cells(NextRow + 1, 1) = Application.UserName
shLog.Cells(NextRow + 1, 2) = Format(Now, "mmmm d, yyyy h:mm AM/PM")
Else
shLog.Cells(NextRow, 1) = Application.UserName
shLog.Cells(NextRow, 2) = Format(Now, "mmmm d, yyyy h:mm AM/PM")
End If
End Sub