I'm trying to delete every row where the cell value for column x does not match the cell value of column y. I keep getting an object error and I'm pretty sure I'm missing something obvious.
Sub Gooddata()
Application.ScreenUpdating = False
lr = Range("C65536").End(xlUp).Row
For a = lr To 1 Step -1
If Cells(a, 8).Value <> Cells(a, 9).Value Then
Cells(a, 3).Select
ActiveCell.EntireRow.Delete = True
End If
Next a
Application.ScreenUpdating = True
End Sub
Edit: I have made edits to the code based on the suggestions of the comments here's the input image the code and the output image.
Sub Gooddata()
Application.ScreenUpdating = False
lr = Range("C65536").End(xlUp).Row
For a = lr To 1 Step -1
If Cells(a, 8).Value <> Cells(a, 9).Value Then
Cells(a, 3).EntireRow.Delete
End If
Next a
Application.ScreenUpdating = True
End Sub
If the code executed in the way that I want it to Old Argus Building 12 will not be deleted however the row below it will because of the comma and dash.