遍历列并替换(如果包含这些值)。如果不保持原样

Go through column and replace if containing these values. If not leave as is

我想遍历 L 列并将包含这些文本字段的单元格替换为 0。否则我想保持原样。代码运行但在它遇到的第一个 #N/A 处停止。

Sub Drops()
    Dim i&, z&
    With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual

        With Sheets("Input")
            i = .Cells(Rows.Count, "L").End(xlUp).Row
            For z = i To 2 Step -1
                If (.Cells(z, "L").Value2 Like "*Customer Dropoff*" _
                    Or .Cells(z, "L").Value2 Like "*RE-Ships No pick up charge*" _
                        Or .Cells(z, "L").Value2 Like "*Undeliverable Publication Mail (NO P/U CHARGE)*" _
                            Or .Cells(z, "L").Value2 Like "*RETURNS*" _
                                Or .Cells(z, "L").Value2 Like "*K2 Fed Ex*" _
                                    Or .Cells(z, "L").Value2 Like "*WorldNet Shipping*" _
                                        Or .Cells(z, "L").Value2 Like "*OSM (NO P/U COST)*" _
                                            Or .Cells(z, "L").Value2 Like "*TEST PICK UP*") Then

                    .Cells(z, "L").Value2 = 0
                End If
            Next z
            z = .Cells(Rows.Count, "L").End(xlUp).Row
        End With

        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
    End With
    MsgBox i - z & " Rows has been changed!"
End Sub

未测试:

Sub Drops()
    Dim i As Long, z As Long, arr, v, n As Long
    Dim numEdits As Long

    numEdits = 0
    arr = Array("Customer Dropoff", "RE-Ships No pick up charge", _
                "Undeliverable Publication Mail (NO P/U CHARGE)") 'etc

    With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
    End With

    With Sheets("Input")
        i = .Cells(Rows.Count, "L").End(xlUp).Row

        For z = i To 2 Step -1

            v = .Cells(z, "L").Value
            If IsError(v) Then
                'ignore error ?
            Else
                For n = LBound(arr) To UBound(arr)
                    If v Like "*" & arr(n) & "*" Then
                        .Cells(z, "L").Value = 0
                        numEdits = numEdits + 1
                        Exit For
                    End If
                Next n
            End If

        Next z

    End With

    With Application
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
    End With

    MsgBox numedits & " Row(s) changed!"

End Sub