I wrote a macro in vba to input a 1 in the rows when the third or fourth column have blank values and then to delete these rows. There are 1500 lines in the file and the macro skips over certain lines. I have to run the macro several times for it to work properly. Is there a reason for this error.
Sub DEX_Clean()
Dim W As Worksheet
Set W = Worksheets("DEX")
For Each i In W.Range("DEX").Rows
If i.Cells(1, 3).Value = "" Or i.Cells(1, 4).Value = "" Then
If i.Cells(1, 1).Value <> "" Then
i.Cells(1, 7).Value = 1
End If
End If
Next i
For Each i In W.Range("DEX").Rows
If i.Cells(1, 1).Value <> "" And i.Cells(1, 7).Value = 1 Then
i.Cells(1, 1).EntireRow.Delete
End If
Next i
End Sub