+ Reply to Thread
Results 1 to 12 of 12

how to delete rows based on duplicate cells

  1. #1
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    how to delete rows based on duplicate cells

    i have a sheet that has duplicate info in column O, i want to keep the first row in the list, and delete the rest of the rows that has the same information in column O. i have a routine that deletes a row based on 0 being in a column, is there a way to use that to do the trick?

    Please Login or Register  to view this content.
    sample data
    COLUMN O IS THE LAST COLUMN IN THIS DATA
    001 Stair Hall 1000 General G&A & Project Management 13 37 481 1000.001 1 001 General G&A & Project Management.Stair Hall 93010
    001 Stair Hall 1100 Bidding 14 41 574 1100.001 1 001 Bidding.Stair Hall 93010
    001 Stair Hall 2570 Bid Meetings 10 37 370 2570.001 1 001 Bid Meetings.Stair Hall 93010
    002 Family Room 1000 General G&A & Project Management 6 41 246 1000.002 1 002 General G&A & Project Management.Family Room 86226.95
    002 Family Room 1100 Bidding 6 49 294 1100.002 1 002 Bidding.Family Room 86226.95
    002 Family Room 2570 Bid Meetings 13 36 468 2570.002 1 002 Bid Meetings.Family Room 86226.95
    Last edited by dmcgov; 01-26-2016 at 02:40 PM. Reason: ADDED SAMPLE DATA

  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: how to delete rows based on duplicate cells

    Does this help?

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how to delete rows based on duplicate cells

    Thanks John,

    I tried what you coded and it deleted some stuff as well as leaving duplicate rows. i will upload a sample sheet with the data on it for you to peruse.

    when you are done with the macro, there should be 4 lines remaining.

    sample data for upload.xlsm

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

    Re: how to delete rows based on duplicate cells

    I tested it and had only 2 row remaining. I understood duplicate too mean duplicates in Column "O" would be the reason to delete rows right? I did modify the code too include row 1 as well since your data did not have a header.

    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how to delete rows based on duplicate cells

    using the sample data, there should be 4 rows remaining. when i ran your routine, it kept only two rows.

    fyi, the data in column A,B and P is duplicate as well.

    so your routine kept fixtures 001 and 002 but missed 003 and 004.

    its close though, just need to fix the missing fixtures
    Last edited by dmcgov; 01-26-2016 at 03:33 PM.

  6. #6
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: how to delete rows based on duplicate cells

    Thanks a lot Mr. John for the code
    Without using any codes :Select all Columns From Column A to Column P
    From Data tab >> Remove Duplicates >> Click Unselect All >> Select Column O only
    That's all
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  7. #7
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: how to delete rows based on duplicate cells

    Quote Originally Posted by dmcgov View Post
    using the sample data, there should be 4 rows remaining. when i ran your routine, it kept only two rows.

    fyi, the data in column A,B and P is duplicate as well.

    so your routine kept fixtures 001 and 002 but missed 003 and 004.
    So the same steps but select column A and Column O

  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: how to delete rows based on duplicate cells

    I probably misunderstood. " want to keep the first row in the list, and delete the rest of the rows that has the same information in column O"

  9. #9
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how to delete rows based on duplicate cells

    yes my bad, want to keep the first in the list and delete any duplicates.

  10. #10
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how to delete rows based on duplicate cells

    Quote Originally Posted by YasserKhalil View Post
    Thanks a lot Mr. John for the code
    Without using any codes :Select all Columns From Column A to Column P
    From Data tab >> Remove Duplicates >> Click Unselect All >> Select Column O only
    That's all
    that leaves two rows instead of 4

  11. #11
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how to delete rows based on duplicate cells

    john, nevermind. the fault was mine as column O had the same values for fixture 2,3 and 4. once i change O to A, then it worked correctly. thanks for your help.

  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: how to delete rows based on duplicate cells

    OK.

    Please Login or Register  to view this content.

+ 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 based on values of cells
    By phixate in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-26-2014, 04:49 PM
  2. [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
  3. Replies: 2
    Last Post: 08-24-2011, 05:42 PM
  4. Delete Duplicate Rows based on All columns
    By king12yan in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-22-2010, 02:36 PM
  5. Delete Duplicate Rows Based only 2 columns.
    By ebbo in forum Excel General
    Replies: 2
    Last Post: 02-18-2010, 11:27 AM
  6. Delete duplicate rows based on all columns
    By kiran654 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 01-30-2010, 08:14 AM
  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