VBA宏不会删除零值的行

我想在特定列中删除具有零值的行。但是,宏仅在某些行中起作用。我以为那是格式问题,所以我尝试更改格式,但不起作用。你能帮我找到问题吗?

Before macro

After macro

    If IsNumeric(Cells(i, 7).Value) And IsNumeric(Cells(i, 8).Value) And IsNumeric(Cells(i, 9).Value) Then
    Else
    Rows(i).EntireRow.Delete
    End If
Next

Worksheets("sheet").Columns("F").NumberFormat = "#,##0.0"
Worksheets("sheet").Columns("G").NumberFormat = "#,##0.0"
Worksheets("sheet").Columns("H").NumberFormat = "#,##0.0"
Worksheets("sheet").Columns("I").NumberFormat = "#,##0.0"

For i = 7 To lastcell
    If Cells(i, 6).Value = 0 And Cells(i, 7).Value = 0 And Cells(i, 8).Value = 0 And Cells(i, 9).Value = 0 Then
    Rows(i).EntireRow.Delete
    End If
Next
评论