Klartigue
06-06-2012, 11:58 AM
I have this expression to delete the rows in which the cell in column D has the value "0" in it.
However this expression only deletes some of the rows where cell D is "0".
Do you see anything wrong with it?
Sub tester2()
Dim lastrow As Long
Dim i As Long
With ActiveSheet
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 2 To lastrow
If .Cells(i, "D").Value = "0" Then
With Range(.Cells(i, "A"), .Cells(i, "X")).Select
Selection.Delete
End With
End If
Next i
End With
End Sub
However this expression only deletes some of the rows where cell D is "0".
Do you see anything wrong with it?
Sub tester2()
Dim lastrow As Long
Dim i As Long
With ActiveSheet
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 2 To lastrow
If .Cells(i, "D").Value = "0" Then
With Range(.Cells(i, "A"), .Cells(i, "X")).Select
Selection.Delete
End With
End If
Next i
End With
End Sub