This is based on your example of 7 columns, but it's easily expanded by changing the array size and columns variable to 27 (or however many you have). Let me know if it's oversimiplified -- I realize your sample data may be just that and your actual data has more complexity than this.
Sub Outline(ws As Worksheet, columns As Integer, offset As Integer)
Dim row, lastRow As Long
Dim index, col As Integer
Dim level As String
Dim values(1 To 255) As Integer
values(1) = 0
lastRow = ws.UsedRange.Rows.Count
For row = 1 To lastRow
For index = 1 To columns
If ws.Cells(row, index).Value <> "" Then
values(index) = values(index) + 1
level = values(1)
If index > 1 Then
For col = 2 To index
level = level & "." & values(col)
Next col
End If
ws.Cells(row, columns + offset).NumberFormat = "@"
ws.Cells(row, columns + offset).Value = level
For col = index + 1 To columns
values(col) = 0
Next col
Exit For
End If
Next index
Next row
End Sub
