忽略使用“和”的IF语句中的空白单元格

时间:2018-05-03 17:38:01

标签: excel excel-vba vba

我目前有以下脚本来搜索4个单元格值。它删除包含10以上所有值的所有行。但是,我正在努力添加嵌套的“IF”语句来忽略空格。

Sub test()

For i = Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
    If Cells(i, "C").Value2 >= 10 And Cells(i, "D").Value2 >= 10 And Cells(i, "E").Value2 >= 10 And Cells(i, "F").Value2 >= 10 Then
        Rows(i).Delete
    End If
Next i

End Sub

1 个答案:

答案 0 :(得分:0)

子测试()

Range("C:F" & LastRow).Replace "", "999", xlWhole

For i = Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
    If Cells(i, "C").Value2 >= 10 And Cells(i, "D").Value2 >= 10 And Cells(i, "E").Value2 >= 10 And Cells(i, "F").Value2 >= 10 Then
        Rows(i).Delete
    End If
Next i

Range("C:F" & LastRow).Replace "999", "", xlWhole


End Sub