If you can add a row above to flag the green cells (as Excel doesn't recognize colour as a condition and you would need VBA for that.. which is not my strength), then see attached.
A added a popular UDF I like to use to concatenate conditionally,
in the VB editor:
Function aconcat(a As Variant, Optional sep As String = "") As String
' Harlan Grove, Mar 2002
Dim y As Variant
If TypeOf a Is Range Then
For Each y In a.Cells
aconcat = aconcat & y.Value & sep
Next y
ElseIf IsArray(a) Then
For Each y In a
aconcat = aconcat & y & sep
Next y
Else
aconcat = aconcat & a & sep
End If
aconcat = Left(aconcat, Len(aconcat) - Len(sep))
End Function
Then formula in V4 would be:
=SUBSTITUTE(SUBSTITUTE(TRIM(aconcat(IF(($B$1:$U$1="x")*($B4:$U4="x"),"x"&$B$3:$U$3,IF($B4:$U4="x",$B3:$U3,""))," "))," ",","),"x"," ")
which must be confirmed with CTRL+SHIFT+ENTER not just ENTER and copied down.
Bookmarks