+ Reply to Thread
Results 1 to 19 of 19

Removing almost duplicate rows

  1. #1
    Forum Contributor
    Join Date
    02-06-2014
    Location
    The Show Me State
    MS-Off Ver
    Excel 2013
    Posts
    343

    Removing almost duplicate rows

    Is there a way to write a macro to remove almost duplicate rows (They are duplicate except for column N)? I want the semi duplicate row to disappear when column N is blank on one of the rows. The rows highlighted in yellow need to go away because N is blank.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    07-14-2017
    Location
    Poland
    MS-Off Ver
    Office 2010
    Posts
    528

    Re: Removing almost duplicate rows

    Check my solution.
    Please Login or Register  to view this content.
    Best Regards,
    Maras.

  3. #3
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Removing almost duplicate rows

    This is another code that checks all 13 columns. Couple of points

    1. The code could be shorter but I'm sorting before running the actual code to ensure that incase the row that doesn't have the word "NEW" comes first (& sorting after to return original sort)
    2. If column "N" doesn't have "NEW" it has a space & not blank
    3. I assume that there's no duplicate row with the word "NEW" more than once

    Please Login or Register  to view this content.
    If I was able to help, you can thank me by clicking the * Add Reputation under my user name

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

    Re: Removing almost duplicate rows

    Try
    Please Login or Register  to view this content.

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,192

    Re: Removing almost duplicate rows

    Unorthodox Method Perhaps...
    Please Login or Register  to view this content.
    Just a side note...Not sure if you noticed the discrepancy in your result file...B4 & E11 values differ from values in example after rows are deleted...Not sure how that happened...
    Last edited by sintek; 06-05-2020 at 03:58 AM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  6. #6
    Forum Contributor
    Join Date
    02-06-2014
    Location
    The Show Me State
    MS-Off Ver
    Excel 2013
    Posts
    343

    Re: Removing almost duplicate rows

    How could I copy and edit this macro to remove all rows where column X (#24) = ND or PD? Or is there a easier macro?
    Last edited by gz3s36; 06-05-2020 at 08:14 AM.

  7. #7
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Removing almost duplicate rows

    Quote Originally Posted by gz3s36 View Post
    But not sure about (Value = " ").
    I guess you're referring to my code which contains Value = " " … If you want to include ND or PD, you could write it like below

    Please Login or Register  to view this content.

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,192

    Re: Removing almost duplicate rows

    macro to remove all rows where column X (#24) = ND or PD?
    Another Option if the above quote is all you want...
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    02-06-2014
    Location
    The Show Me State
    MS-Off Ver
    Excel 2013
    Posts
    343

    Re: Removing almost duplicate rows

    Thank you again.

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

    Re: Removing almost duplicate rows

    Thanks for the rep.

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

  11. #11
    Forum Contributor
    Join Date
    02-06-2014
    Location
    The Show Me State
    MS-Off Ver
    Excel 2013
    Posts
    343

    Re: Removing almost duplicate rows

    You Guru's never cease to amaze me. Thanks for all the help.

  12. #12
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,192

    Re: Removing almost duplicate rows

    Thanks for rep + ... Glad we could contribute...

  13. #13
    Forum Contributor
    Join Date
    02-06-2014
    Location
    The Show Me State
    MS-Off Ver
    Excel 2013
    Posts
    343

    Re: Removing almost duplicate rows

    Nankw83: This worked great for one file but it doesn't for another. The only changes I made are P1 to N1, (x, 14 to x, 16) and Sheet1 to sheet2. Any ideas? it stops on .UsedRange.Resize(, lCol + 1).Sort Key1:=Range("N1"), Order1:=xlDescending, Header:=xlYes

    Please Login or Register  to view this content.
    Last edited by gz3s36; 06-06-2020 at 06:30 AM.

  14. #14
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,192

    Re: Removing almost duplicate rows

    I suggest when you post you address the correct member...i.e.

    @ nankw83

    With reference to your code in Post # etc etc etc

  15. #15
    Forum Contributor
    Join Date
    02-06-2014
    Location
    The Show Me State
    MS-Off Ver
    Excel 2013
    Posts
    343

    Re: Removing almost duplicate rows

    Thank you for the tip

  16. #16
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Removing almost duplicate rows

    Quote Originally Posted by gz3s36 View Post
    Nankw83: ... Any ideas? it stops on .UsedRange.Resize(, lCol + 1).Sort Key1:=Range("N1"), Order1:=xlDescending, Header:=xlYes
    Ok, I have added option explicit & assign some ranges to the ws … Give the below code a try & see if it works. If it still doesn't work, then we need to see a sample file

    Please Login or Register  to view this content.

  17. #17
    Forum Contributor
    Join Date
    02-06-2014
    Location
    The Show Me State
    MS-Off Ver
    Excel 2013
    Posts
    343

    Re: Removing almost duplicate rows

    Here is my test file.
    Attached Files Attached Files
    Last edited by gz3s36; 06-06-2020 at 09:19 AM.

  18. #18
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Removing almost duplicate rows

    You need to convert the table to range in order for my code to work. To do that, click anywhere in the table then from the Ribbon click Table Design then Convert to Range

    Also I noticed that in the below line you change the 13 to 100 however, your table has only 56 columns

    Please Login or Register  to view this content.

  19. #19
    Forum Contributor
    Join Date
    02-06-2014
    Location
    The Show Me State
    MS-Off Ver
    Excel 2013
    Posts
    343

    Re: Removing almost duplicate rows

    It wasn't in a table so the tab wasn't showing up.
    Last edited by gz3s36; 06-06-2020 at 12:10 PM.

+ 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. Removing Duplicate Rows
    By virtualized in forum Excel General
    Replies: 3
    Last Post: 02-18-2012, 09:58 AM
  2. Removing Unwanted Rows and summing the duplicate Rows
    By Cena in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-08-2010, 07:00 AM
  3. removing duplicate rows
    By Xtopher in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-26-2009, 07:15 PM
  4. removing duplicate rows
    By jartzh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-20-2008, 01:25 PM
  5. RE: removing duplicate rows
    By Chris Marlow in forum Excel General
    Replies: 0
    Last Post: 03-02-2006, 05:10 AM
  6. removing duplicate rows
    By exceluser2 in forum Excel General
    Replies: 3
    Last Post: 03-01-2006, 09:55 PM
  7. Add in for removing duplicate rows?
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-14-2005, 04:15 PM
  8. Removing Duplicate Rows
    By bvinternet in forum Excel General
    Replies: 1
    Last Post: 07-23-2005, 05:05 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