Excel VBA: 按照条件插入行



Sub Macro1()

    Dim softwareVersion As String
    Dim recentFlag      As String
    Dim historyFlag     As String
    Dim maxRowsNumber   As Long
    Dim targetColumn    As Integer
    Dim imageColumn     As Integer
   
    maxRowsNumber = 65535
    recentFlag = "Y"
    historyFlag = "N"
    targetColumn = 8
    imageColumn = 10
   
    'Enter the newest version in this place
    softwareVersion = "3.08.00"

    For i = 7 To maxRowsNumber Step 1
   
       If Cells(i, 6) = recentFlag Then
            Rows(i).Copy
           
            Rows(i + 1).Insert
            Cells(i, 6) = historyFlag
           
            Cells(i + 1, 6) = recentFlag
            Cells(i + 1, 8) = softwareVersion
            Cells(i + 1, 10) = softwareVersion
           
            i = i + 1
        ElseIf Cells(i, 6) = "" Then
       
            i = maxRowsNumber
           
        End If
       
    Next i
   
End Sub


Sub Macro1()

    Dim SoftwareVersion As String
    SoftwareVersion = "3.08.00"

    For i = 7 To 65535 Step 1
   
       If Cells(i, 6) = "Y" Then
            Rows(i).Copy
           
            Rows(i + 1).Insert
            Cells(i, 6) = "N"
           
            Cells(i + 1, 6) = "Y"
            Cells(i + 1, 8) = SoftwareVersion
            Cells(i + 1, 10) = SoftwareVersion
           
            i = i + 1
        ElseIf Cells(i, 6) = "" Then
            i = 65535
        End If
       
    Next i
   
End Sub


   



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值