我在Excel中有一组数据。人口以年为单位数百万,但是我需要填写的数据存在差距。看下面的例子用于线性系列填充的Excel宏
Year--2013--2014--2015--2016--2017--2018--2019--2020
Male-- 5-- -- 7-- -- -- 8-- -- 10
Fem-- 4-- -- 5-- -- -- 7-- -- 9
我知道我可以使用填充/系列/线性,但我需要从2000年至2050年为数百个国家做到这一点。我试图记录我这样做的宏,但Step Value似乎是硬编码的。
这是甚至可能或我咬牙,继续手动?
感谢
Ĵ
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
为什么不告诉我们你录制的内容?所有来自宏录像机的*都是*硬编码的,但通常它可以很容易地修改... – 2014-10-27 15:32:20
我现在已经包含了我记录的宏,这有帮助吗? – jellybean1977 2014-10-28 10:38:07
步数值代表什么?如果你能确定它们是如何分配的,应该很容易把它放在一个循环中。 – 2014-10-28 13:55:50