Function ElapTimeAdd(pfirst As String, pnext As String) As String
'***********************************************
're: [URL unfurl="true"]http://www.tek-tips.com/viewthread.cfm?qid=1222502&page=1[/URL]
'Purpose: Add two elapsed times and display result in hh:mm:ss format
'coded by: raskew
'Inputs: from debug (immediate) window
' 1) ? ElapTimeAdd("12:05:15", "10:25:03")
' 2) ? ElapTimeAdd("12:05", "10:25")
'Outputs: 1) 22:30:18
' 2) 22:30:00
'***********************************************
Dim firsthold As Long
Dim nexthold As Long
Dim inthold As Long
Dim inthours As Integer
Dim intmins As Integer
Dim intsecs As Integer
' 1) Convert input to seconds and add
firsthold = (3600 * Val(Left(pfirst, 2))) + (60 * Val(Mid(pfirst, 4, 2))) + Val(Mid(pfirst, 7, 2))
nexthold = (3600 * Val(Left(pnext, 2))) + (60 * Val(Mid(pnext, 4, 2))) + Val(Mid(pnext, 7, 2))
inthold = firsthold + nexthold
' 2) Convert inthold to elapsed hours, minutes and seconds
inthours = inthold \ 3600
intmins = (inthold Mod 3600) \ 60
intsecs = (inthold Mod 3600) Mod 60
' 3) Format and output result
ElapTimeAdd = Format(str(inthours), "00") & ":" & Format(str(intmins), "00") & ":" & Format(str(intsecs), "00")
End Function