Excel增加行数并且增加日期,且自动保留相同数据

Dim x As Integer, y As Integer, z As Integer, n As Integer

 z = Sheet6.Range("a65536").End(xlUp).Row   '一共有多少行数
 y = 3   '根据不同的情形需要调整
    
    For n = 0 To z    '控制整体循环的次数
     If Cells(y - 1, "B").Value <> 0 Then
      rows(y).Resize(Cells(y - 1, "B").Value).Insert
        For x = 1 To Cells(y - 1, "B").Value '该循环是为了将插入空行中添加日期
          Cells(y, "C").Value = Cells(y - 1, "C").Value
           Cells(y, "F").Value = Cells(y - 1, "F").Value
 Cells(y, "G").Value = Cells(y - 1, "G").Value
 Cells(y, "H").Value = Cells(y - 1, "H").Value
 Cells(y, "I").Value = Cells(y - 1, "I").Value
 Cells(y, "J").Value = Cells(y - 1, "J").Value
 Cells(y, "K").Value = Cells(y - 1, "K").Value
 Cells(y, "L").Value = Cells(y - 1, "L").Value
 Cells(y, "M").Value = Cells(y - 1, "M").Value
 Cells(y, "N").Value = Cells(y - 1, "N").Value
 Cells(y, "O").Value = Cells(y - 1, "O").Value
 Cells(y, "P").Value = Cells(y - 1, "P").Value
 Cells(y, "Q").Value = Cells(y - 1, "Q").Value
 Cells(y, "R").Value = Cells(y - 1, "R").Value
 Cells(y, "S").Value = Cells(y - 1, "S").Value
 Cells(y, "T").Value = Cells(y - 1, "T").Value
 Cells(y, "U").Value = Cells(y - 1, "U").Value
 Cells(y, "V").Value = Cells(y - 1, "V").Value
 Cells(y, "W").Value = Cells(y - 1, "W").Value
 Cells(y, "X").Value = Cells(y - 1, "X").Value
 Cells(y, "Y").Value = Cells(y - 1, "Y").Value
 Cells(y, "Z").Value = Cells(y - 1, "Z").Value
 Cells(y, "AA").Value = Cells(y - 1, "AA").Value
 Cells(y, "AB").Value = Cells(y - 1, "AB").Value
 Cells(y, "AC").Value = Cells(y - 1, "AC").Value
 Cells(y, "AD").Value = Cells(y - 1, "AD").Value
 Cells(y, "AE").Value = Cells(y - 1, "AE").Value
         Cells(y, "A").Value = DateAdd("m", Cells(y - 1, "C").Value, Cells(y - 1, "A").Value)   'dateadd函数直接添加月份
         y = y + 1 
        Next
    End If
        y = y + Cells(y - 1, "B").Value + 1
    Next n

  • 7
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值