I have some code in my VBA script that is supposed to delete entire rows when the value of the respective B column of the row equals zero. Unfortunately, the lines of code I have been using are not doing exactly what I want as it deletes the entire row if ANY of the cells in the respective row equals zero. Here is the code so far:
With Worksheets("Sheet2")
For myloop = .Range("B10000").End(xlUp).Row To 1 Step -1
If .Cells(myloop, 4).Value = 0 Then .Rows(myloop).EntireRow.Delete
Next myloop
End With
For instance I had a row in which the cell in column D was equal to zero and this code deleted the entire row even though the value of the cell in column B was not zero. How can I change the code so it actually only scans for the entries in column B?
Any help is appreciated and thanks in advance.
.Cells(myloop, 4).Value
to.Cells(myloop, 2).Value
– gizlmo