It would be to complex to do this with native Excel functions...
You could probably create VBA code to do it.....
If you are willing to add a free addin to Excel called Morefunc.xll from this site: http://xcell05.free.fr/morefunc/english/ ,which is used by many of us in this and other forums, then you can apply the following formula to E3:
=MCONCAT(IF(MATCH(TRUE,($A3:$A$40<>""),0)+1<=MATCH(TRUE,($A4:$A$41<>""),0)+1,B3:INDEX($B3:$B$40,MATCH(TRUE,($A4:$A$41<>""),0)),""),", ")
which must be confirmed with CTRL+SHIFT+ENTER not just ENTER. You will see { } brackets appear around the formula. Then you can copy it down.
If you adjust any ranges, etc.. you need to re-confirm the formula.
Note: In order to avoid error on the last row.. enter anything (e.g. "X" in column A of the row after your last entry in column B.
See attached... (won't work if you don't have the addin installed).
Bookmarks