+ Reply to Thread
Results 1 to 12 of 12

Delete rows based on duplicate column values?

  1. #1
    Registered User
    Join Date
    12-18-2017
    Location
    London
    MS-Off Ver
    2007
    Posts
    26

    Delete rows based on duplicate column values?

    Hi there and thanks in advance for any help.

    How do you delete entire rows based on duplicates in certain columns? I want to search for duplicates in column C and D and then delete entire rows where this occurs. Example, in the sheet below I want to delete row number 4. Obviously we are talking about sheets where there are thousands of rows. Need a quick way to either isolate or auto delete these rows please.

    Capture01.PNG

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Delete rows based on duplicate column values?

    Here is one way
    Please Login or Register  to view this content.
    Last edited by gmr4evr1; 12-18-2017 at 08:45 PM.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Delete rows based on duplicate column values?

    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  4. #4
    Registered User
    Join Date
    12-18-2017
    Location
    London
    MS-Off Ver
    2007
    Posts
    26

    Re: Delete rows based on duplicate column values?

    Quote Originally Posted by gmr4evr1 View Post
    Here is one way
    Please Login or Register  to view this content.
    Sorry, my fault...I actually have 5 columns A-E and it's columns D and E I want to check duplicates in. Possible to rewrite the code for me please? Thanks so much for your time!

  5. #5
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Delete rows based on duplicate column values?

    Try changing
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-18-2017
    Location
    London
    MS-Off Ver
    2007
    Posts
    26

    Re: Delete rows based on duplicate column values?

    Quote Originally Posted by gmr4evr1 View Post
    Try changing
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    It worked! Thanks so much, you've saved years of my life!

  7. #7
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Delete rows based on duplicate column values?

    No problem, glad it worked for you. Thanks for the rep

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Prof Plus 2021
    Posts
    7,018

    Re: Delete rows based on duplicate column values?

    To avoid errors(matching rows that didn't get deleted) deleting rows is always done from bottom to top or in 1 go using specialcells.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  9. #9
    Registered User
    Join Date
    12-18-2017
    Location
    London
    MS-Off Ver
    2007
    Posts
    26

    Re: Delete rows based on duplicate column values?

    Quote Originally Posted by gmr4evr1 View Post
    No problem, glad it worked for you. Thanks for the rep
    I need to modify this a bit. I realized I need to go through the results instead of deleting the rows straight away. Now I need to do the same thing but instead of it auto deleting the rows I need to put a value 1 in column F if there is a row match in columns D and E. This will allow me to then sort the whole sheet by column F and I can go through the results to then delete the rows I don't want manually.

    Possible?

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Prof Plus 2021
    Posts
    7,018

    Re: Delete rows based on duplicate column values?

    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    Last edited by bakerman2; 12-19-2017 at 05:03 AM.

  11. #11
    Registered User
    Join Date
    12-18-2017
    Location
    London
    MS-Off Ver
    2007
    Posts
    26

    Re: Delete rows based on duplicate column values?

    Quote Originally Posted by bakerman2 View Post
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    Pure brilliance!!

    (The 1 got input into column G rather than column F but it's all good!)

    Thanking you kindly.

  12. #12
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Prof Plus 2021
    Posts
    7,018

    Re: Delete rows based on duplicate column values?

    Glad to help. Thanks for rep+.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Delete rows based on duplicate names in 1 column if they contain a value in a second ?
    By myk2thestar23 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-25-2017, 04:51 PM
  2. Delete Duplicate rows with duplicate in 1 column based on value from another column
    By CraigR&M in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-30-2016, 04:36 PM
  3. Delete Duplicate rows with duplicate in 1 column based on value from another column
    By CraigR&M in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-30-2016, 02:06 PM
  4. Delete rows having duplicate values in a specific column
    By kre30a in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-24-2015, 02:37 PM
  5. Delete duplicate rows based on values of cells
    By phixate in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-26-2014, 04:49 PM
  6. Replies: 5
    Last Post: 11-12-2012, 08:38 PM
  7. Replies: 5
    Last Post: 05-29-2006, 09:25 AM

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