Okay, try this.
With Sheet2
In A4
=LOOKUP(REPT("Z",255),CHOOSE({1;2},"",INDEX(Sheet1!$A$5:$A$1000,MATCH(TRUE,INDEX(ISNA(MATCH(Sheet1!$A$5:$A$1000,$A$3:$A3,0)),0),0))))
Drag/Fill Down as required.
In B4 this array formula
=IF($A4="","",IF(SUMIF(Sheet1!$A$5:$A$1000,$A4,Sheet1!B$5:B$1000)=0,"",
IF(B$3="Start",MIN(IF(--(Sheet1!$A$5:$A$1000=$A4),IF(Sheet1!B$5:B$1000>0,Sheet1!B$5:B$1000))),
IF(B$3="Finish",MAX(IF(--(Sheet1!$A$5:$A$1000=$A4),Sheet1!B$5:B$1000)),""))))
Confirm with Ctrl+Shift+Enter not just Enter.
Drag Across to Column V, then Down as required.
Hope this helps.
Bookmarks