Option Explicit
Sub abc()
Dim a, i, j, s, t
With ActiveSheet
a = .[a1].CurrentRegion.Resize(.UsedRange.Rows.Count).Value
For i = 2 To UBound(a)
For j = 1 To UBound(a, 2)
If Len(a(i, j)) Then
If Len(s) = 0 Then s = a(1, j)
t = t & "," & a(1, j) & "-" & a(i, j)
End If
Next
If Len(t) Then
If InStr(2, t, ",") Then a(i, 1) = Mid(t, 2) Else a(i, 1) = s
s = vbNullString: t = s
End If
Next
a(1, 1) = Empty
.[a1].Offset(, UBound(a, 2) + 1).Resize(UBound(a)) = a
End With
End Sub