+ Reply to Thread
Results 1 to 8 of 8

Delete Dublicate rows based on multi column values

  1. #1
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Delete Dublicate rows based on multi column values

    HI I have this working code. It delete the all the dublicates rows, based on value in Column A,B,C. I would like to know how i can expand this code, so it delete the dublicate rows based on example column A, B, C ,D Or even with maybe column E also.

    I have to used this code to find the dublicates in a sheet with around 12000 rows. I use Excel 2003.

    If there could be a code with a input box for the range or columns which shall be used, it would really be perfect. So i have the possibility to change it after the need.

    Please have a look

    Thanks in advance
    Abjac

    Here is my code.

    Please Login or Register  to view this content.
    I put a little testsample worksheet with some date to test on.It wil now delete the last 10 rows based on the value for column A;B;C
    But if it would be included with column D, it should not delete any.

    Have a look thanks
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Delete Dublicate rows based on multi column values

    I have tested your data, using columns A,B and C and found some duplicated lines, but when I included column D, I could not find duplicates. Tyr it.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Delete Dublicate rows based on multi column values

    HI AB33
    I tested your code and it seems it work like a dream. I changed some numbers in column d and it found them and deleted the 2 i have changed.
    After i tried on a big file with 10000 rows and just copied 5000 and added them. And it deleted the new 5000 added and also quite fast.
    So it looks like it really works. I need of course to see on a real file where the date is mixed and where i know i have dublicates.
    But so far really great thanks.
    For my understanding of your code, please explain to me.
    This line

    Jnme = Join$(Array(.Cells(i, 1), .Cells(i, 2), .Cells(i, 3), .Cells(i, 4), Chr(124)))
    Here its included column A, B, C, D right?
    And if i change i like this
    Jnme = Join$(Array(.Cells(i, 1), .Cells(i, 2), .Cells(i, 3), Chr(124)))
    Its column A, B, C right?
    And this one
    Jnme = Join$(Array(.Cells(i, 1), .Cells(i, 2), .Cells(i, 3), .Cells(i, 4),.Cells(i, 5), Chr(124)))
    I have column A, B, C ,D,E right?

    But what do this do Chr(124)))
    ???
    And finally i think of how its possible to put in a inputbox in this code, so i can choose, how many columns i will use?

    Please have a look

    And thanks for now

    Abjac

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Delete Dublicate rows based on multi column values

    Abjac,
    Please wrap your code, otherwise by replying to this thread I am also breaking forum's rule.
    Yes, you are right about the array-jnme. Just change the cells numbers to suite your needs.
    chr(124) is a "Piper" joiner. You could use any joiner, be comma.hyphen, back slash,etc. You are spoiled with choices
    The reason of using the chr no is I do not know how to locate that piper on my key board- no other reason.
    Sorry! I do not know you incorporate the input box in to this code.

  5. #5
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Delete Dublicate rows based on multi column values

    HI AB33.

    Sorry about the missing wrap, forgot because it was only a string of it. If i understand you correct i can set up all example this formula


    Please Login or Register  to view this content.
    And the numbers 1,2,3,4,5 indicate Column A;B;C;D;E right?
    Can i leave one of them blank example with out any number and will it be ok? JUst to know, when i will try make the input box
    And i guess i can put 3 in with example number 1,2,4 And it will look for the value in column A,B D correct?

    Sincerly Abjac

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Delete Dublicate rows based on multi column values

    Abjac,
    Yes, you are right!
    Numbers are columns. You could also used "Range" instead if you wish.

    Please Login or Register  to view this content.
    What the line does? Join the ranges and use that joined range to test if the same joined range also exist on the loop.
    I am not sure what do you mean by blank, but would be easier not to include it in the first place, but you can play around and if the array does not like, it will give you an error.
    Last edited by AB33; 01-19-2013 at 03:04 PM.

  7. #7
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Delete Dublicate rows based on multi column values

    Thanks AB33. Its really a great code and thank you also for so fast and competent answer. I think i get the understanding, which is great.
    And the inputboxes, i will find out of i think later on. So its really great. Thanks allot.

    Sincerely Abjac

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Delete Dublicate rows based on multi column values

    Abjac,
    You are welcome and glad to be helpful!

+ 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