+ Reply to Thread
Results 1 to 6 of 6

macro to find duplicates in a sheet( 2-3 lacs rows) based on key column

  1. #1
    Registered User
    Join Date
    11-02-2012
    Location
    banglore
    MS-Off Ver
    Excel 2010
    Posts
    11

    macro to find duplicates in a sheet( 2-3 lacs rows) based on key column

    I m looking for macro which finds duplicates quickly in huge excel sheet based on some key column/s and either put the data in another sheet or highlight in that sheet only.

    The key column can be a single column or multiple columns.

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: macro to find duplicates in a sheet( 2-3 lacs rows) based on key column

    Hello prachi b,

    Something like the attached WorkBook perhaps?

    Also see the "Please consider" note at the bottom of this post.
    Attached Files Attached Files
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Registered User
    Join Date
    11-02-2012
    Location
    banglore
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: macro to find duplicates in a sheet( 2-3 lacs rows) based on key column

    Thanx Winon for a quick response.
    But this is not according to my requirement.

    Consider the following entries in an excel sheet below -

    ID Amt Remarks Month
    ---- -------- ------------------- -----------
    1 200.00 Balance November
    2 456.59 Paid November
    3 344.08 Balance November
    1 157.02 Balance November
    2 456.59 Paid November

    Case 1:
    Consider ID as key column. For ID "1", there are two records which are considered as duplicates.

    ID Amt Remarks Month
    ---- -------- ------------------- -----------
    1 200.00 Balance November
    1 157.02 Balance November

    Case 2:
    Considering ID column and Amt column as key column,now there are two duplicates records as follows:


    ID Amt Remarks Month
    ---- -------- ------------------- -----------
    2 456.59 Paid November
    2 456.59 Paid November


    Likewise there can be any combination of key columns to identify duplicates in a sheet.
    Is there a single which can handle these cases.
    Please let me know if you have any questions.

    Thanks in advance.

  4. #4
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: macro to find duplicates in a sheet( 2-3 lacs rows) based on key column

    Hello prachi b,

    Likewise there can be any combination of key columns to identify duplicates in a sheet.
    Is there a single which can handle these cases.
    I don't believe you can use a single Macro to identify your key columns. You will have to tell the Program where to look for duplicates, and what you specify as a "Key".

    The revised Sample WorkBook should give you a fair indication of how it works, and you can expand from thereon.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-02-2012
    Location
    banglore
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: macro to find duplicates in a sheet( 2-3 lacs rows) based on key column

    Hey Winon,


    Sub ShowDups()

    Dim x As Long
    Dim LastRow As Long

    LastRow = Range("A65536").End(xlUp).Row
    For x = LastRow To 1 Step -1
    If Application.WorksheetFunction.CountIf(Range("A1:A" & x), Range("A" & x).Text) > 1 Then
    Range("A" & x).Cells.Resize(, 3).Interior.ColorIndex = 8
    End If
    Next x


    End Sub

    In the above code where you are defining key column....pls let me know...so that i can change the key column whenever requirred.

    And also pls guide how we can pass key column to macro...

    sry for troubling...
    i m a new in macro world....

  6. #6
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: macro to find duplicates in a sheet( 2-3 lacs rows) based on key column

    If you just want to identify the duplicates then why don't use just use Conditional Formatting >> Highlight Cell Rules >> Duplicate values?
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1