Hi,
I have data with 20000 observations over time. Time span is 1969 to 2011 for different categories. Not for every category there are observations for every year, so I would like to insert a row for the missing years, containing the value 0 in the "observation" cell.
Example:
Year Age Observation
1969 0 4
1970 0 17
1972 0 6
...
...
1969 1 5
1970 1 22
....
You see for example that for age 0 the year 1971 is missing, as there are no observations. I would like to insert a row here, indicating 0 obervations.
My macro looks like this so far:
Sub macro1()
Dim i As Long
i = 3
Do Until Trim(Cells(i, 1)) = ""
If Cells(i, 1) <> Cells(i - 1, 1)+1 Then
Cells(i, 1).EntireRow.Insert
Cell(i + 1, 1) = Cell(i, 1)+1
Cell(i + 1, 2) = Cell(i, 2)
Cell(i + 1, 3) = 0
i = i + 2
Else
i = i + 1
End If
Loop
End Sub
It is not working...what am I doing wrong?
Thanks a lot!!
Bookmarks