取H列的值到数组A
从C1/D1/E1 ... 开始循环查找日期值,看哪一列的日期值与数组A(1,1)的值相等?
若找到日期值相等的格子,则可以确定:把数据输出到哪一列 ?
再用resize()方法,把数组的内容输出到这一列.
大致思路就是这样.有了思路,代码不难写.
程序代码:Sub CopyData()
' Define source and destination ranges
Dim sourceRange As Range
Dim destRange As Range
Set sourceRange = Range("A2:A11")
Set destRange = Range("C2:C11").Offset(0, ActiveSheet.Range("H1").Value - Date)
' Copy data from source to destination
destRange.Value = sourceRange.Value
End Sub