OK. I set up 6 Named ranges to make the formula look simpler. CTRL-F3 to view edit. They select the range of the table for each action needed in SUMPRODUCT.
They are all based on the use of INDEX;MATCH to select the column of the arrival time the column to the left of it and the column to the right of it (A_Rng0, A_RngMinus and A_RngPlus) and similarly for the departure time. The SUMPRODUCT then looks like this:
=IFERROR(IF(E$5<$D6,"",SUMPRODUCT((A_Rng0<>"")*(A_Rng0<>A_RngMinus)*(D_Rng0<>"")*(D_Rng0<>D_RngPlus))),"")
REMEMBER the Named Ranges MUST extend ONE column to the RIGHT of the last column with data.
N.B. You said: "the matrix shows four vehicles arriving at 0830 and leaving at 0915, whereas only three do (SD19, J333 and SL61)". In fact there are four. You forgot to count SH66.
Bookmarks