Off the top
Code:With Activesheet lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row For i = lastrow to 1 Step -1 If Not IsError(Application.Match(.Cells(i, "A").Value, .Columns(2),0)) Then .Cells(i, "A").Delete Shift:=xlUp End If Next i End With
Off the top
Code:With Activesheet lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row For i = lastrow to 1 Step -1 If Not IsError(Application.Match(.Cells(i, "A").Value, .Columns(2),0)) Then .Cells(i, "A").Delete Shift:=xlUp End If Next i End With
Here is an alternative that I think will work, it doesn't delete the cell in column A, just clears the text from it.Code:Sub deleteA() Dim endRow As String Sheets("Sheet1").Select endRow = Range("A65536").End(xlUp).Row Range("A1", "A" & endRow).Select For Each cell In Selection cell.Select i = ActiveCell.Row If Range("A" & i) = Range("B" & i) Then ActiveCell.Clear Next End Sub
HTH
Aidan
Bookmarks