vendredi 24 avril 2020

VBA Macro is not droping rows with zero values

I want to drop the rows with zero values in specific columns. However, the macro just works in some rows. I thought that was a format issue so I tried changing the format but it doesn't work. Could you help me find the problem?

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

Aucun commentaire:

Enregistrer un commentaire