我有一个现有的宏,它将费用数据填充到KM列中的三个相邻单元格(约300行),我想复制这些单元格中的数据(相同顺序),并根据月份值粘贴特殊值短期日期位于AA栏。复制的数据需要粘贴到与源相同的行中,但是列N-Y(标题= Jan,Feb,March,Apr ... Dec)。有代码可以做到吗?
Column| K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | AA |
Header| $ | $ | $ | J | F | M | A | M | J | J | A | S | O | N | D |FY |Date|
Row 3 |978|540|395|-->|-->|978|540|395| | | | | | | |1913|5/11|
Row 4 |841|779|120|-->|-->|-->|-->|841|779|120| | | | | |1740|7/24|
Row 5 |682|557| 55|-->|-->|-->|-->|-->|-->|682|557| 55| | | |1294|9/18| ' Row 6 |985|883|578|-->|-->|-->|-->|-->|-->|-->|-->|->|985|883|578|2446|12/2|
答案 0 :(得分:0)
试试这个:
Sub MoveData()
Dim vals As Range, val As Range, colOffset As Integer
Set vals = Range("K2:K" & Range("K2").End(xlDown).Row)
For Each val In vals
If val > 0 Then
colOffset = VBA.month(val.offset(0, 16))
val.offset(0, colOffset) = val
val.offset(0, colOffset + 1) = val.offset(0, 1)
val.offset(0, colOffset + 2) = val.offset(0, 2)
End if
Next val
End Sub