Function TotTime(ParamArray VarMyVals() As Variant) As Variant
'*******************************************
'Name: TotTime (Function)
'Purpose: Process an array of "hh:mm" hours
' and minutes:
' (1) Determine total # of minutes
' (2) Convert (1) to hh:mm string
'Author: R Askew, 6-Oct 03
'Inputs: From the debug window:
' ? tottime("10:00", "9:12", "13:23", "14:52")
'Output: Total minutes = 2847 (from debug.print)
' 47:27
'*******************************************
Dim idx As Long
Dim numHrs As Integer, numMins As Integer, minHold As Integer
Dim strHrs As String, strMins As String
minHold = 0
For idx = 0 To UBound(VarMyVals()) 'loop thru the array
numHrs = val(Left(VarMyVals(idx), InStr(VarMyVals(idx), ":") - 1))
numMins = val(Mid(VarMyVals(idx), InStr(VarMyVals(idx), ":") + 1))
minHold = minHold + val((60 * numHrs) + numMins)
Next idx
Debug.Print "Total minutes = " & minHold
'Having created number of minutes as an integer,
'we now want to display it as a string in hh:mm format
strHrs = Int(minHold / 60)
strMins = Format(minHold Mod 60, "00")
TotTime = strHrs & ":" & strMins
End Function