+ Reply to Thread
Results 1 to 6 of 6

Delete rows that contain duplicate data in one column

  1. #1
    Registered User
    Join Date
    05-28-2009
    Location
    Oxford
    MS-Off Ver
    Excel 2007
    Posts
    86

    Delete rows that contain duplicate data in one column

    I am trying to delete rows (with macro) that contain duplicate data in a specific column.

    So I may have:


    John Smith 01/01/1990 Ref:111
    Jane Smith 02/02/1990 Ref:123
    John Smith 00/00/0000 Ref:111


    If the ref is the same then the whole row should be deleted. The rest of the row will not be the same. So the result would be:

    John Smith 01/01/1990 Ref:111
    Jane Smith 02/02/1990 Ref:123

    Thanks.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Delete rows that contain duplicate data in one column

    So, when we're deleting, we're deleting the secondary ones, keeping the first. Also, can you tell me what column those ref values are in?
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Delete rows that contain duplicate data in one column

    Here's a stock macro I have for this, I've put the REF in column C, if that's wrong, change that reference before running the macro:
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    05-08-2004
    Posts
    16

    Re: Delete rows that contain duplicate data in one column

    Quote Originally Posted by JBeaucaire View Post
    Here's a stock macro I have for this, I've put the REF in column C, if that's wrong, change that reference before running the macro:
    Please Login or Register  to view this content.
    Should the code LastRow = Range("A"... be LastRow = Range("C"... ? Also, can this be easily modified to NOT leave a row that contained one of the duplicate values? So the only rows remaining after the macro is run are the rows that contained unique values initially in column C. Thanks.

  5. #5
    Registered User
    Join Date
    05-28-2009
    Location
    Oxford
    MS-Off Ver
    Excel 2007
    Posts
    86

    Re: Delete rows that contain duplicate data in one column

    Excellent thank you.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Delete rows that contain duplicate data in one column

    You can solve for LR in any column and then use it in any range, but in this simplest of application it probably SHOULD be initially solved in column C, too. Only the OP (or you in your own sheet) really know the best way to solve then use the LastRow variable.

    ==========
    If that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].




    (Also, use the blue "scales" icon in our posts to leave Reputation Feedback, it is appreciated)

+ Reply to 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