I have a set of data in excel. Population in millions by year, however there are gaps in the data that I need to fill. See example below
Year--2013--2014--2015--2016--2017--2018--2019--2020
Male-- 5-- -- 7-- -- -- 8-- -- 10
Fem-- 4-- -- 5-- -- -- 7-- -- 9
I know I can use Fill/Series/Linear, but I need to do this for hundreds of Countries from 2000-2050. I tried to record a macro of me doing it, but the Step Value seems to be hard coded.
Is this even possible or do I bite the bullet and continue manually?
Thanks
J
Sub FillTheGaps()
'
' fill the gaps Macro
'
'start at cell A2
'find first gap on that row
Selection.End(xlToRight).Select
'select up to and including next non-blank
Range(Selection, Selection.End(xlToRight)).Select
Selection.DataSeries Rowcol:=xlRows, Type:=xlLinear, Date:=xlDay, Step _
:=11845, Trend:=False
Selection.End(xlToLeft).Select
'move down to next row
ActiveCell.Offset(1).Select
Selection.End(xlToRight).Select
'select up to and including next non-blank
Range(Selection, Selection.End(xlToRight)).Select
Selection.DataSeries Rowcol:=xlRows, Type:=xlLinear, Date:=xlDay, Step _
:=8598, Trend:=False
Selection.End(xlToLeft).Select
'move down to next row
ActiveCell.Offset(1).Select
Selection.End(xlToRight).Select
'select up to and including next non-blank
Range(Selection, Selection.End(xlToRight)).Select
Selection.DataSeries Rowcol:=xlRows, Type:=xlLinear, Date:=xlDay, Step _
:=30400, Trend:=False
'move down to next row
ActiveCell.Offset(1).Select
End Sub