You could use this UDF (user defined function) which returns a #VALUE! error if the number of dates between the two cells is not the same...
Function SumTimeDiff(EarlyTimes As String, LateTimes As String) As Double
Dim X As Long, ETimes As Variant, LTimes As Variant
ETimes = Split(EarlyTimes, ",")
LTimes = Split(LateTimes, ",")
If UBound(ETimes) = UBound(LTimes) Then
For X = LBound(LTimes) To UBound(LTimes)
SumTimeDiff = SumTimeDiff + CDate(LTimes(X)) - CDate(ETimes(X))
Next
Else
SumTimeDiff = CVErr(xlErrValue)
End If
End Function
HOW TO INSTALL UDFs
------------------------------------
If you are new to UDFs, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. You can now use SumTimeDiff just like it was a built-in Excel function. For example,
=SumTimeDiff(A1,B1)
If you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
Bookmarks