簡體   English   中英

VBA Excel-根據兩列中兩個值的語句結果刪除整行

[英]VBA excel - delete entire row based on the outcome of statement based on two values in two columns

如何使用For循環刪除整個行,該循環檢查該行兩列中的值是否小於一個數字。 這就是我下面的內容。

For Each row In Sheet4.Range("A6:AJ500").Cells
    If Columns("G").value < 500 And Columns("J").value < 50 _
    Then row.EntireRow.Delete
    Next

您需要向后循環:

Sub foo()
  For i = 500 To 6 Step -1
    If Cells(i, "G") < 500 and Cells(i, "J") < 50 Then
      Rows(i).Delete
    End If
  Next i
End Sub

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM