Closed Thread
Results 1 to 9 of 9

Macro to find duplicate values

  1. #1
    Registered User
    Join Date
    01-25-2009
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    4

    Macro to find duplicate values

    I have 2 columns of data. Column 1 has unique values but column 2 has some duplicates of values in column 1. There are about 3000 values in the columns.

    I would make active a cell in column 1 then run the macro to find and goto the duplicate value in column 2. Then run again to find if it is duplicated again etc.

    Is this possible?

    I have attached a sample file.

    Thanks
    Liz
    Attached Files Attached Files

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello lizzieb,

    Welcome to the Forum!

    Do want to use worksheet formulas to find the duplicates or a VBA macro? What do you want to do with the duplicates once you have found them?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    01-25-2009
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    4

    Macro to find duplicate values

    Hi Leith

    I am not very knowledgeable on these things so don't really know what I want to use. However I had thought I would use Conditional Formatting to highlight in red the cells that had duplicate values.

    Then click on the first cell in column 1 that has duplicates, and run a Macro which would take me to the cell in column 2 with the duplicated value. Then run it again to see if there was a second duplicate of it in column 2 etc. Then if there was no more duplicates of the original value in column 1 the macro would say "no more!"

    Then I would start the whole process again with the next duplicated value in column 1.

    When the duplicates are found I just want to assess them manually. Not do anything with them.

    I tried recording a macro by making the first duplicated cell active then start the macro. Copy the value onto the clipboard, open the find box, paste the contents of clipboard, find next, close, press escape and stop Macro. However this created a macro with just a value in the find box instead of a variable clipboard value.

    So I have to give up.

    Hope you can help. I am sure it is easy but I can't work it out.

    Thanks
    Liz

  4. #4
    Registered User
    Join Date
    01-16-2009
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    16
    If you want to find duplicates using worksheet formulas then use a countif function and autofilter the results.

    If you want to find duplicates using code then use this code

    Please Login or Register  to view this content.
    working example for both methods:
    Attached Files Attached Files
    Craig Holmes
    Microsoft Office Specialist Master Instructor
    Excel Training Courses Sydney | Microsoft Office Excel VBA Courses

  5. #5
    Registered User
    Join Date
    01-25-2009
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    4

    Macro to find duplicates

    Wow - thanks. The Duplicates using VBA is great.

    I think that is so much better than I was trying to do.

    I shall try it out on the proper data tomorrow and let you know.

    Many many thanks


    Liz

  6. #6
    Registered User
    Join Date
    01-25-2009
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Macro to find duplicate values

    Dear caholmes
    My friend is so pleased with your work. So many thanks. I have now spent the day reading how to use VBA as I would love to understand how it all works. I owe you. Do you have a Paypal account?

    Cheers

    Liz

  7. #7
    Registered User
    Join Date
    06-04-2010
    Location
    India
    MS-Off Ver
    Excel 2003/2007
    Posts
    5

    Re: Macro to find duplicate values

    Really thank you so much Mr.
    Last edited by smstha; 06-04-2010 at 03:36 PM.

  8. #8
    Registered User
    Join Date
    06-04-2010
    Location
    India
    MS-Off Ver
    Excel 2003/2007
    Posts
    5

    Re: Macro to find duplicate values

    Hi
    Assume my data starting from A:
    Then I used to use formula to near column
    =IF(COUNTIF($A$2:A2,A2)=1,COUNTIF(A:A,A2),"")
    Then it will provide result that how many times it is repeated cell.
    In this case I need Macro,
    Any suggest, please?
    Thanks in advance.
    Smstha
    Chennai

  9. #9
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Macro to find duplicate values

    smstha,

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.

Closed Thread

Thread Information

Users Browsing this Thread

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

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