+ Reply to Thread
Results 1 to 13 of 13

Remove duplicate if column B is blank

  1. #1
    Forum Contributor
    Join Date
    03-08-2011
    Location
    London
    MS-Off Ver
    Work Office 365 Home 2019
    Posts
    427

    Remove duplicate if column B is blank

    Hi Guys,

    I'm looking for a macro that will sort column A in alphabetical order (It does have a header), check for duplicates in column A and if duplicates exist, check if the corresponding cell in column B is blank. If it is then delete the row where column B is blank.

    i.e.

    Column A|Column B
    d1mwork |
    d1mwork | French
    d2mwork |
    d2mwork | French

    Becomes
    Column A|Column B
    d1mwork | French
    d2mwork | French

    Thanks all!

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

    Re: Remove duplicate if column B is blank

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Remove duplicate if column B is blank

    See if this help.

    Please Login or Register  to view this content.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  4. #4
    Forum Contributor
    Join Date
    03-08-2011
    Location
    London
    MS-Off Ver
    Work Office 365 Home 2019
    Posts
    427

    Re: Remove duplicate if column B is blank

    Spot on John! - Many Thanks (rep added )

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

    Re: Remove duplicate if column B is blank

    You're welcome. Glad to help out and thanks for the feedback.

  6. #6
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Remove duplicate if column B is blank

    @John
    Did I miss something?

  7. #7
    Forum Contributor
    Join Date
    03-08-2011
    Location
    London
    MS-Off Ver
    Work Office 365 Home 2019
    Posts
    427

    Re: Remove duplicate if column B is blank

    Just taking this one step further, what would I need to add (and where) if I also wanted to remove duplicate entries (where column A and column B match exactly?)

    Thanks

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

    Re: Remove duplicate if column B is blank

    Quote Originally Posted by sktneer View Post
    @John
    Did I miss something?
    I think your version deletes all blank rows where Column B is blank, even when there are no duplicates.

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

    Re: Remove duplicate if column B is blank

    Quote Originally Posted by MagicMan View Post
    Just taking this one step further, what would I need to add (and where) if I also wanted to remove duplicate entries (where column A and column B match exactly?)

    Thanks
    Try:

    Please Login or Register  to view this content.

  10. #10
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Remove duplicate if column B is blank

    Quote Originally Posted by JOHN H. DAVIS View Post
    I think your version deletes all blank rows where Column B is blank, even when there are no duplicates.
    I think, it would delete a row with blank in col. B if value in col. A is not unique i.e. it is a duplicate. And I assume that following line of code does this.....

    Please Login or Register  to view this content.
    Did you try this?
    Last edited by sktneer; 04-23-2015 at 07:52 AM. Reason: Typo

  11. #11
    Forum Contributor
    Join Date
    03-08-2011
    Location
    London
    MS-Off Ver
    Work Office 365 Home 2019
    Posts
    427

    Re: Remove duplicate if column B is blank

    Thanks again John,

    That didn't work (of course it might just be me! ) But I've put this in and at the end of your code I've made it call

    Please Login or Register  to view this content.
    Not that it makes any difference, but at least they can be operated in isolation.

    But thank you again for allowing me to take up your valuable time. :D

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

    Re: Remove duplicate if column B is blank

    Quote Originally Posted by sktneer View Post
    I think, it would delete a row with blank in col. B if value in col. A is not unique i.e. it is a duplicate. And I assume that following line of code does this.....

    Please Login or Register  to view this content.
    Did you triy this?
    I hadn't tested it. But it certainly does work. Good insight for a different approach.

  13. #13
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Remove duplicate if column B is blank

    Quote Originally Posted by JOHN H. DAVIS View Post
    I hadn't tested it. But it certainly does work. Good insight for a different approach.
    hmm.......

+ 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. [SOLVED] MultiLine Textbox to auto remove blank line, count line, remove duplicate
    By khhoa in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-24-2015, 09:28 PM
  2. Replies: 1
    Last Post: 06-01-2013, 01:27 AM
  3. Remove rows with duplicate values in one column based on value of another column
    By jolleyje in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-15-2013, 06:20 AM
  4. [SOLVED] Remove duplicate and blank with formula
    By ssimo2 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-16-2013, 03:40 PM
  5. Sort - Merge Current Data into blank cells, remove duplicate information
    By cannedyams in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-27-2012, 04:08 PM

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