EinarOSies
Board Regular
- Joined
- Feb 15, 2021
- Messages
- 61
- Office Version
- 2019
- Platform
- Windows
I have been working on a code to calculate the amount of time being used when closing a workbook. These are my line of code:
The idea of my code is that when I open my workbook it should store the opening time in sheet @OVERALL TOTAL DETAILS cell A41, thus Worksheets("OVERALL TOTAL DETAILS").Range("A41").Value2 = =Format(Now,"dd/mmmm/yyyy hh:mm:ss:ms") is in the Open Event.
So when closing the workbook it should display a message box showing the used time in working with the workbook.
VBA Code:
Sub VBA_Calculate_Minutes_Between_Two_Times()
Dim sTime As Date, eTime As Date
Dim iValue As Integer
Worksheets("OVERALL TOTAL DETAILS").Range("A41").Value2 = sTime
Now() = eTime
iValue = DateDiff("n", sTime, eTime)
MsgBox "The amount of time you used to work is " & iValue, vbInformation, ""
End Sub
So when closing the workbook it should display a message box showing the used time in working with the workbook.