Great, thank you so much for the super quick help, millz!!
The code works very well and without errors now! I edited it a little though, as it counted the years on to infinity, instead of starting after year 2011 again at 1969 for the next age class. In case somebody ever needs sth like this again, here the final version.
Sub macro1()
Dim i As Long
i = 3
Do Until Trim(Cells(i, 1)) = "" Or Trim(Cells(i + 1, 1)) = ""
If Cells(i + 1, 1).Value <> Cells(i, 1).Value + 1 Then
If Cells(i, 1).Value = 2011 Then
If Cells(i + 1, 1).Value <> 1969 Then
Cells(i + 1, 1).EntireRow.Insert shift:=xlDown
Cells(i + 1, 1) = 1969
Cells(i + 1, 2) = Cells(i + 2, 2)
Cells(i + 1, 3) = Cells(i + 2, 3)
Cells(i + 1, 4) = Cells(i + 2, 4)
Cells(i + 1, 5) = Cells(i + 2, 5)
Cells(i + 1, 6) = 0
End If
Else: Cells(i + 1, 1).EntireRow.Insert shift:=xlDown
Cells(i + 1, 1) = Cells(i, 1) + 1
Cells(i + 1, 2) = Cells(i, 2)
Cells(i + 1, 3) = Cells(i, 3)
Cells(i + 1, 4) = Cells(i, 4)
Cells(i + 1, 5) = Cells(i, 5)
Cells(i + 1, 6) = 0
End If
End If
i = i + 1
Loop
End Sub
Bookmarks