These are tested in Open Office. May need modifying for Excel.
Contatenate cells B5 - F5, inserting a comma and line break, only if the cell is not blank
=IF(TRIM(LEN(B5));B5&","&CHAR(10);"")&IF(TRIM(LEN(C5));C5&","&CHAR(10);"")&IF(TRIM(LEN(D5));D5&","&CHAR(10);"")&IF(TRIM(LEN(E5));E5&","&CHAR(10);"")&IF(TRIM(LEN(F5));F5;"")