Excell delete row where column A = column B

[Closed]
Report
-
Posts
7098
Registration date
Saturday April 7, 2007
Status
Moderator
Last seen
June 10, 2021
-
Hello,

This should be simple but I can't find the solution. I need to delete rows from a spreadsheet where column A = column B.

Please help.


3 replies

Posts
2
Registration date
Friday February 24, 2012
Status
Member
Last seen
February 24, 2012

If you want to delete column A but maintain the values in column B you have to copy over the with copy as the values from A to B first. Then delete column A.
I need to remove the entire row or record for column A and B if A = B.

ex.

A B
1 1
2 5
18 18
6 90

keep
2 5
6 90
Posts
7098
Registration date
Saturday April 7, 2007
Status
Moderator
Last seen
June 10, 2021
488
Hi,

You can do it by using a VBA macro :

Public Sub DELETE_Rows_rowA_id_rowB()  
Dim x As Long  
Dim y As Long  
x = Range("A65536").End(xlUp).Row  

For y = x To 2 Step -1  

    If Cells(y, 1).Value = Cells(y, 2).Value Then  
      
        Rows(y).Delete  
      
    End If  

Next y  
End Sub  


Best regards

"Pour trouver une solution à ses problèmes, il faut s'en donner la peine."