excel 匹配条件以查找空白行并填充列中的值

dl5txlt9  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(127)


的数据
在共享表中,如果活动正在固化,我希望填充值& order=NextOrder
我尝试使用Range.fillup,但它只填充1个值,也无法选择活动和订单的标准

pobjuy32

pobjuy321#

Option Explicit
Sub Demo()
    Dim i As Long, j As Long
    Dim arrData, rngData As Range
    Const KEY_ACT = "Curling"
    ' Load data
    Set rngData = ActiveSheet.Range("A1").CurrentRegion
    arrData = rngData.Value
    ' Loop through each row
    For i = UBound(arrData) - 1 To LBound(arrData) + 1 Step -1
        ' Compare Activtiy
        If StrComp(arrData(i, 1), KEY_ACT, vbTextCompare) = 0 Then
            ' Compare Order
            If StrComp(arrData(i, 2), arrData(i + 1, 2), vbTextCompare) = 0 Then
                ' Populate Seq
                If Len(Trim(arrData(i, 3))) = 0 And Len(Trim(arrData(i + 1, 3))) > 0 Then
                    arrData(i, 3) = arrData(i + 1, 3)
                End If
            End If
        End If
    Next i
    ' Update table
    rngData.Value = arrData
End Sub

字符串


的数据

相关问题