如果滿足條件,B列中的值小於100,我試圖刪除excel中的一行。我看到this並試圖關注它,但我不是那種VBA知識淵博的人,所以我不知道該去哪裏。如果值小於X,則在Excel中刪除行
編輯 這是我到目前爲止試過的代碼,它不起作用。
Sub DeleteR()
Dim myRow As Range
Dim toDelete As Range
For i = 2 To 5000
If Worksheets("PalCountPLTZR").Cells(i, 2) < "99" Then
Set myRow = Worksheets("PalCountPLTZR").Rows(i)
If toDelete Is Nothing Then
Set toDelete = myRow
Else
Set toDelete = Union(toDelete, myRow)
End If
End If
Next i
End Sub
我不知道爲什麼它不工作,但我想知道如果它看細胞是從查詢。
這裏有一些其他的方法; https://stackoverflow.com/questions/33744149/code-in-vba-loops-and-never-ends-how-to-fix-this嘗試這些,當你陷入困境,請帶上你試過的代碼,並解釋你調整它,爲什麼它不工作。 –