+ Reply to Thread
Results 1 to 16 of 16

Remove duplicate row if cell is blank

  1. #1
    Registered User
    Join Date
    12-18-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010
    Posts
    55

    Remove duplicate row if cell is blank

    Hi,

    I am back again to seek some experts help. I have below code which checks duplicates in column B & C and remove the entire row.
    Is it possible that if duplicate found macro should remove row which have blank cell in column D?

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Remove duplicate row if cell is blank

    You can run this macro after your dup routine.

    Please Login or Register  to view this content.
    HTH
    Regards, Jeff

  3. #3
    Registered User
    Join Date
    12-18-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Remove duplicate row if cell is blank

    Thanks Jeffrey,

    This code is deleting all the rows if cells in column D are blank. I am sorry if I was not very clear in my 1st post.
    The DelDup code is deleting the second instance if duplicate found. For example values in cell B2 & C2 are identical with values in B10 & C10 so it will delete row 10. However I want that it should check cell D2 & D10, if D2 is blank then it should delete row 2 instead of row 10. IF D10 is blank then delete row 10 and if D2 & D10 both are blank or non-blank then it should delete row 10.

    Hope I am clear... sorry, I am not so good with vba.

    Is it possible??

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Remove duplicate row if cell is blank

    Okay, please attach a sample workbook with a clear before and after. This helps see exactly what you need and also helps in the testing process.

  5. #5
    Registered User
    Join Date
    12-18-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Remove duplicate row if cell is blank

    Hi,

    In the attached file row 3 and row 10 have identical values in column B & C, the macro in post 1 will delete row 10 however I need that it should check column D in both rows and delete the row which have blank cell, if both rows have blank cell or if both rows have values in column D then delete row 10

    If it is possible, this will be big help for me, since I used to work on 25000 - 30000 rows of data 4-5 times a day.

    Thanks in advance.
    Attached Files Attached Files

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Remove duplicate row if cell is blank

    With you attached sample file, try this...

    No need for the first macro in post #1

    Please Login or Register  to view this content.
    In the empty column, column J, I've used a formula to capture your dup/blank criteria and then delete the row.

    If you use F8 to step thru the code it will give you a good idea as to what is happening.

  7. #7
    Registered User
    Join Date
    12-18-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Remove duplicate row if cell is blank

    Thanks for your efforts, Jeffrey

    The above macro is not deleting any row if both rows have values in column D and deleting both rows if cells are blank in column D

    We are close but not yet

  8. #8
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Remove duplicate row if cell is blank

    Not quite all the way there yet, but here is what I have so far.

    In this dummy sheet, as I understand your requirement, the rows in shaded in "brown" should be removed.

    I'm getting stuck on the last removal of the row where column D is blank on one dup and filled on the other.

    More to come...
    Attached Files Attached Files

  9. #9
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Remove duplicate row if cell is blank

    Maybe this will work Jeff

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Remove duplicate row if cell is blank

    Please Login or Register  to view this content.
    Last edited by jindon; 05-28-2017 at 01:41 AM. Reason: Formula has been changed

  11. #11
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Remove duplicate row if cell is blank

    NOTE: This code uses the 'RemoveDuplicates' method, intro'd with Excel 2010. charm1 uses Excel 2003. OOPS!
    Or this - Sort and Remove Duplicates:
    Please Login or Register  to view this content.
    NOTE: Second sort returns list to original order. If that's unnecessary, use this:
    Please Login or Register  to view this content.
    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee
    Last edited by leelnich; 05-28-2017 at 06:37 PM.

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Remove duplicate row if cell is blank

    Quote Originally Posted by leelnich View Post
    Or this - Sort and Remove Duplicates:
    It will be easy if OP is not on 2003...

  13. #13
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Remove duplicate row if cell is blank

    TRUE - Thanks for pointing that out. RemoveDuplicates was intro'd Excel 2010. I'll leave it as useful for later versions.

  14. #14
    Registered User
    Join Date
    12-18-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Remove duplicate row if cell is blank

    Thanks leelnich, jindon, mike7952 & jeffrey for taking your time out and providing the solution.

    I have adopted leelnich code with a small change in one line
    Please Login or Register  to view this content.
    this dosent mean that other's code dosent work but with my limited knowledge of VBA I found leelnich's code is easiest to modify to fulfill my need.

    As always you all are rockstar
    Many Many Thanks

  15. #15
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Remove duplicate row if cell is blank

    Happy to help!, but I have to ask: Did you note my (and jindon's) remarks re: Office version. According to your profile, seen to the left of your posts, you use Excel 2003. The RemoveDuplicates method WILL NOT WORK with that version, as it was introduced in 2010. If you have updated, you should amend your profile to reflect that, as we use that info to tailor our answers to YOUR version - unless we miss it, as I did . -Lee

  16. #16
    Registered User
    Join Date
    12-18-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Remove duplicate row if cell is blank

    Yes leelnich... I do use office 2010 and updated this info in my profile... thanks so much

    Marked this thread as SOLVED.

    Thanks everyone!

+ 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. Remove Blank cell and duplicate value
    By Rashidul in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 09-06-2015, 12:45 PM
  2. Remove Blank cell and duplicate value
    By Rashidul in forum Non English Excel
    Replies: 1
    Last Post: 09-04-2015, 01:35 PM
  3. [HELP] me to remove duplicate values and leave that cell as blank
    By spa3212 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-30-2015, 01:23 PM
  4. [HELP] me to remove duplicate values and leave that cell as blank
    By spa3212 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-30-2015, 12:55 AM
  5. [SOLVED] Remove duplicate if column B is blank
    By MagicMan in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 04-23-2015, 07:52 AM
  6. [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
  7. [SOLVED] Remove duplicate and blank with formula
    By ssimo2 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-16-2013, 03:40 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