Compare two cells, and deletes on if duplicate

miketran

New Member
Joined
Jul 15, 2011
Messages
14
I have a simple problem looking for a simple solution.

I want to compare two columns, A and B, and delete the A cells that are equal to the B cells...I have 3000 rows...

If Cell A1 = B1, Then Delete A1, next row...

Thanks for any help you can give me on this!
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Here's one way
Code:
Sub DeleteColumnA2()
    Dim I As Integer
    For I = 1 To Range("A" & Rows.Count).End(xlUp).Row
        If Cells(I, "A").Value = Cells(I, "B").Value Then
            Cells(I, "A").Value = ""
        End If
    Next I
End Sub

it sets the cell in column A to blank when the value is equal to that in column B
 
Upvote 0
You need VBA to do this. However you can do this by using the following formula in C1 cell and copy it to C2:C3000. Then filter column "C" with "Duplicate" and clear the values of "A" column.

=IF(COUNTIF($B$1:$B$3000,$A1)>0,"Duplicate","No Duplicate")

Regards,

A.B. Mati
Doha, Qatar
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,249
Members
452,623
Latest member
Techenthusiast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top