VBA Coding for calculating an average amount of time using military time.

  • Thread starter Thread starter Mattine
  • Start date Start date
M

Mattine

Guest
How would I calculate an average amount of time using military time? This is the code that I am using to calculate the amount of time it takes to do something, can it be modified to show an average? Thank-you!!

Option Explicit
Function GetElapsedTime(interval)

Dim totalhours As Long, totalminutes As Long, totalseconds As _
Long
Dim days As Long, hours As Long, Minutes As Long, Seconds As Long

days = Int(CSng(interval))
totalhours = Int(CSng(interval * 24))
totalminutes = Int(CSng(interval * 1440))
totalseconds = Int(CSng(interval * 86400))
hours = totalhours Mod 24
Minutes = totalminutes Mod 60
Seconds = totalseconds Mod 60

GetElapsedTime = days & " Days " & hours & " Hours " & Minutes & _
" Minutes " & Seconds & " Seconds "

End Function
 

Users who are viewing this thread

Back
Top Bottom