+ Reply to Thread
Results 1 to 8 of 8

Delete rows based on duplicate names in 1 column if they contain a value in a second ?

  1. #1
    Registered User
    Join Date
    01-25-2017
    Location
    USA
    MS-Off Ver
    Plus 2016
    Posts
    5

    Question Delete rows based on duplicate names in 1 column if they contain a value in a second ?

    I need to know if it is possible to delete all rows with duplicate names in column A if Column B contains a value for any of those rows with that same name?

    Example Below: I need to be able to delete ALL rows below that have the name "APPLE" in Column A if any of those rows contains a "1" in Column B. So in this case, ALL 4 rows with "APPLE" need to be deleted even though the first row with "APPLE" doesn't contain a "1" in Column B. The same goes for name "DOG".

    Column A Column B

    BOOK
    BOOK
    APPLE
    APPLE 1
    APPLE 1
    APPLE 1
    CAT
    CAT
    CAT
    CAT
    DOG 1
    DOG
    Last edited by myk2thestar23; 01-25-2017 at 04:16 AM.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Delete rows based on duplicate names in 1 column if they contain a value in a second ?

    Try this code, place it in the worksheet module
    Please Login or Register  to view this content.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    01-25-2017
    Location
    USA
    MS-Off Ver
    Plus 2016
    Posts
    5

    Re: Delete rows based on duplicate names in 1 column if they contain a value in a second ?

    Thank You!!! You just saved me lots of manual hours of work. Doing this manually already took me 3 hours and I still have 2,000 + more rows to go through. This is working perfect!! Thanks again!!

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Delete rows based on duplicate names in 1 column if they contain a value in a second ?

    You're welcome.
    Don't forget to mark the post solved

  5. #5
    Registered User
    Join Date
    01-25-2017
    Location
    USA
    MS-Off Ver
    Plus 2016
    Posts
    5

    Re: Delete rows based on duplicate names in 1 column if they contain a value in a second ?

    Keebellah, I'm sorry. After running the macro on the huge spreadsheet, it didn't delete all the rows I expected. Did I do something wrong? I need it to delete all rows of the same name in Column A, even if column B only has one row with a "1" in it for that same name in Column A.

    Example Below: I need it to delete ALL the rows with the name "Cat" even though 3 of the rows don't have a "1".

    Column A.........Column B

    Cat................1
    Cat................
    Cat................1
    Cat................
    Cat................

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete rows based on duplicate names in 1 column if they contain a value in a second ?

    Maybe:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-25-2017
    Location
    USA
    MS-Off Ver
    Plus 2016
    Posts
    5

    Re: Delete rows based on duplicate names in 1 column if they contain a value in a second ?

    Thanks John, I am running it now. It seemed to work on a small worksheet. I am running it on the big one. I really appreciate the help. It will definitely save me a lot of manual work! I'll post once it finishes running. I have over 30K rows

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Delete rows based on duplicate names in 1 column if they contain a value in a second ?

    That was NOT what you asked .... but I see you've got another answer.

+ 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 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
  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: 1
    Last Post: 11-30-2016, 02:06 PM
  3. [SOLVED] Vba to sum up rows based on column a & b and delete duplicate rows
    By kevivu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-05-2016, 03:15 PM
  4. highlight duplicate rows and delete based on highest value from column
    By adnan5586 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-10-2015, 02:05 AM
  5. [SOLVED] Delete rows based on duplicate cell, but leaving first and last duplicate.
    By LadyNicole in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-28-2013, 05:07 AM
  6. Replies: 5
    Last Post: 05-29-2006, 09:25 AM
  7. [SOLVED] delete duplicate names in a column
    By jaya in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 10-21-2005, 05:05 AM

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