• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Find Duplicate with Macro

jack999

Member
I have an excel file with Product ID and Description Column. I want a macro to find out the Duplicate entries in that sheet. Herewith I attached a sample file.
 

Attachments

  • sample.xlsx
    8.6 KB · Views: 0
Select the range("A3:B24")
Go to Data in the ribbon > Click Remove Duplicates

In VBA
Code:
Sub Test()
    Range("A2:B" & Cells(Rows.Count, 1).End(3).Row).RemoveDuplicates Columns:=Array(1, 2), Header:=xlYes
End Sub
 
Select the range("A3:B24")
Go to Data in the ribbon > Click Remove Duplicates

In VBA
Code:
Sub Test()
    Range("A2:B" & Cells(Rows.Count, 1).End(3).Row).RemoveDuplicates Columns:=Array(1, 2), Header:=xlYes
End Sub

If my file has 14 – 15 columns and its range start from B6 what changes will come in this code.


Can you explain this code - Cells(Rows.Count, 1).End(3).Row) and Columns:=Array(1, 2),

New file attached
 

Attachments

  • sample1.xlsm
    19.1 KB · Views: 1
Try this
Code:
Sub Test()
    Range("B7:N" & Cells(Rows.Count, "B").End(3).Row).RemoveDuplicates
End Sub

Columns:=Array(2, 3), Header:=xlYes
This part (Cells(Rows.Count, "B").End(3).Row) refers to the last row in column B
 
Back
Top