Hello, I have the following piece of code which checks that if Column 7 is NOT within 1% of column 11 or column 12 then delete. The problem is the value in 11 or 12 could be a zero and we can't divide by zero. How can I do something that says if Col. 11 is zero skip that and look at 12 or if col 12 is zero skip that and look in col 11?
Sub deleteif()
Endrow = Range("G65536"
.End(xlUp).Row
For i = Endrow To 2 Step -1
If Abs(Cells(i, 7).Value - Cells(i, 11).Value) / Cells(i, 11).Value > 0.01 Then
If Abs(Cells(i, 7).Value - Cells(i, 12).Value) / Cells(i, 12).Value > 0.01 Then
Cells(i, 7).EntireRow.Delete
End If
End If
Next i
End Sub
Sub deleteif()
Endrow = Range("G65536"
For i = Endrow To 2 Step -1
If Abs(Cells(i, 7).Value - Cells(i, 11).Value) / Cells(i, 11).Value > 0.01 Then
If Abs(Cells(i, 7).Value - Cells(i, 12).Value) / Cells(i, 12).Value > 0.01 Then
Cells(i, 7).EntireRow.Delete
End If
End If
Next i
End Sub