首页 > 解决方案 > 忽略使用“与”的 IF 语句中的空白单元格

问题描述

我目前有以下脚本来搜索 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

标签: excelvba

解决方案


子测试()

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

推荐阅读