+ Reply to Thread
Results 1 to 3 of 3

Macro to delete duplicate rows based on empty cells

  1. #1
    Registered User
    Join Date
    08-24-2011
    Location
    Vancouver, BC
    MS-Off Ver
    Excel 2010
    Posts
    1

    Macro to delete duplicate rows based on empty cells

    Hi all, I was wondering if someone can help me with my excel problem using a macro.


    A | B | C
    INV # TRANS # LEDGER #
    ---------- ---------- -------------
    1 12345 T12345 LED123
    2 12345 T12345
    3 67890 T67890 LED123
    4 67890 T67890
    5 88888 T88888

    Based on above example, I would like to be able to delete row 2 and row 4 because row 2 and 4 are duplication of row 1 and 3 respectively. Notice that C2 and C4 is empty. I do not want to delete row 5 because there isn’t a duplication and column C5 is empty. So once I run the macro it would look like this:


    A | B | C
    INV # TRANS # LEDGER #
    ---------- ---------- -------------
    1 12345 T12345 LED123
    2 67890 T67890 LED123 <-- this used to be row 3 from above example
    3 88888 T88888 <-- this used to be row 5 from above example


    Right now I am deleting these about 1500 rows manually and it’s very time consuming. Hopefully this makes sense to you and you are able to help.

    Thanks.
    Last edited by 100d; 08-24-2011 at 03:30 PM. Reason: More descriptive title to be in compliance with the rules

  2. #2
    Forum Contributor yay_excel's Avatar
    Join Date
    08-12-2011
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    190

    Re: Macro to delete duplicate rows based on empty cells

    Are the duplicated rows always directly underneath the rows you wish to keep? If so:

    Please Login or Register  to view this content.
    This also depends on there being no blank rows in your data.

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Macro to delete duplicate rows based on empty cells

    sorry this made a wrong assumption
    ok try number 2
    column labels in a1 b1
    in d2 put
    =SUMPRODUCT(--($A$2:A2=A2),--($B$2:B2=B2))>1
    data/filter advanced filter
    list range a1:b5000
    criteria range
    $D$1:$D$2
    filter in place
    delete visible rows
    Last edited by martindwilson; 08-24-2011 at 07:13 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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