Sub ROLLUP()
Dim c As Range
Dim Col As Integer
Col = 1
For Each c In Range("a2:a879")
'Level 1
If c.Value = "" Then
Cells(c.Row, 33).Value = Cells(c.Row - 1, 33).Value
Else
Cells(c.Row, 33).Value = c.Value
GoTo Skip
End If
'Level 2
If Cells(c.Row, 2) = "" Then
Cells(c.Row, 32).Value = Cells(c.Row - 1, 32).Value
If Cells(c.Row, 3) >= 10000 And Cells(c.Row, 3) <= 99999 Then
Col = 3
GoTo Centre_No
End If
Else
Cells(c.Row, 32).Value = Cells(c.Row, 2).Value
GoTo Skip
End If
'Level 3
If Cells(c.Row, 3) = "" Then
Cells(c.Row, 31).Value = Cells(c.Row - 1, 31).Value
If Cells(c.Row, 4) >= 10000 And Cells(c.Row, 4) <= 99999 Then
Col = 4
GoTo Centre_No
End If
Else
Cells(c.Row, 31).Value = Cells(c.Row, 3).Value
GoTo Skip
End If
'Level 4
If Cells(c.Row, 4) = "" Then
Cells(c.Row, 30).Value = Cells(c.Row - 1, 30).Value
If Cells(c.Row, 5) >= 10000 And Cells(c.Row, 5) <= 99999 Then
Col = 5
GoTo Centre_No
End If
ElseIf Cells(c.Row, 4) >= 10000 And Cells(c.Row, 4) <= 99999 Then
Col = 4
GoTo Centre_No
Else
Cells(c.Row, 30).Value = Cells(c.Row, 4).Value
GoTo Skip
End If
'Level 5
If Cells(c.Row, 5) = "" Then
Cells(c.Row, 29).Value = Cells(c.Row - 1, 29).Value
If Cells(c.Row, 6) >= 10000 And Cells(c.Row, 6) <= 99999 Then
Col = 6
GoTo Centre_No
End If
ElseIf Cells(c.Row, 5) >= 10000 And Cells(c.Row, 5) <= 99999 Then
Col = 5
GoTo Centre_No
Else
Cells(c.Row, 29).Value = Cells(c.Row, 5).Value
GoTo Skip
End If
'Level 6
If Cells(c.Row, 6) = "" Then
Cells(c.Row, 28).Value = Cells(c.Row - 1, 28).Value
Col = 7
GoTo Centre_No
ElseIf Cells(c.Row, 6) >= 10000 And Cells(c.Row, 6) <= 99999 Then
Col = 6
GoTo Centre_No
Else
Cells(c.Row, 28).Value = Cells(c.Row, 6).Value
Col = 7
GoTo Centre_No
End If
GoTo Skip:
Centre_No:
If Val(Cells(c.Row, Col)) >= 10000 And Val(Cells(c.Row, Col)) <= 99999 Then Cells(c.Row, 27).Value = Cells(c.Row, Col).Value
Skip:
Next
End Sub