Delete an entire Row if 2 Columns = Zero Q

J

John

The code below deletes the entire row starting upwards from row 500 if the
value in H=0, but if E=VAT then ignore regardless if H in that particular
row = 0.

For i = Range("E500").End(xlUp).Row To 2 Step -1
If Left(Range("E" & i).Value, 3) <> "VAT" Then
If Range("H" & i).Value = 0 Then
Range("H" & i).EntireRow.Delete
End If
End If
Next i


I wish to modify this slightly that even if E=VAT the row will still be
deleted if L=0. So in effect if H & L are "both" Zero, delete the entire
row. How would I do that

Thanks
 
T

Tom Ogilvy

For i = Range("E500").End(xlUp).Row To 2 Step -1
If Left(Range("E" & i).Value, 3) <> "VAT" or _
Range("L" & i).Value = 0 Then
If Range("H" & i).Value = 0
Range("H" & i).EntireRow.Delete
End If
End If
Next i
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top