Hi,
In the code below I want to check if the cell in column J contains 0 (zero). If it does I want to delete the corresponding row. I want to put this in loop so that it checks the entire sheet for this condition and deletes rows where ever the value in cell (row, J) = 0. The problem is that the code below only deletes one row and does not go back in the loop to check for other cells in column J. My data starts from row 4.
Any help is greatly appreciated.
Sub test()
Dim lastrow As Long
Dim i As Long
Sheets("Sheet1").Select
lastrow = Worksheets("Sheet1").Range("J4").End(xlDown).Row
For i = lastrow To 4 Step -1
If Sheets("Sheet1").Cells(i, "J") = 0 Then
Sheets("Sheet1").Cells(i, "J").EntireRow.Delete shift:=xlUp
' Exit For
End If
Next i
End Sub
Bookmarks