This should work and be flexible.
Formula:
{=SUM(IFERROR(TIMEVALUE(MID(CLEAN($G8),(ROW(INDIRECT("1:"&LEN(G8)-LEN(SUBSTITUTE(G8,"-",""))))-1)*11+7,5)),0)-IFERROR(TIMEVALUE(MID(CLEAN($G8),(ROW(INDIRECT("1:"&LEN(G8)-LEN(SUBSTITUTE(G8,"-",""))))-1)*11+1,5)),0))}
Note that it is an array formula. Close with [Ctrl]+[Shift]+[Enter]
Explaination:
It's about this part of the formula:
Formula:
....MID(Text,StartPos,NumOfChars).....(ROW(INDIRECT("1:"&LEN(G8)-LEN(SUBSTITUTE(G8,"-",""))))-1)*11+7....
Text is G8 where Clean() strips off any unprintable characters like CR and/or LF.
StartPos is calculated by
Formula:
....MID(Text,StartPos,NumOfChars).....(ROW(INDIRECT("1:"&LEN(G8)-LEN(SUBSTITUTE(G8,"-",""))))-1)*11+7....
for the right time and
Formula:
....MID(Text,StartPos,NumOfChars).....(ROW(INDIRECT("1:"&LEN(G8)-LEN(SUBSTITUTE(G8,"-",""))))-1)*11+1....
for the left time
The StartPos is different for each line and needs to be calculated by x*11+7 and x*11+1. Where x = {0,1,2,3,4,5,6}
The function ROW(1:7)-1 gives you the array x. However you need to construct that function with INDIRECT() as ROW() doesn't directly take variable values.
The number of elements in the array x is determined by the number of lines in the cell. That is calculated by counting the number of "-" in the cell.
Once this way times are isolated they are converted to their time values and these are subtracted to get the elapsed times.
IFERROR is there because an empty cell in column G would give an error.
Bookmarks