+ Reply to Thread
Results 1 to 11 of 11

Search for duplicates in two sheets, and delete row if duplicate

  1. #1
    Registered User
    Join Date
    06-26-2014
    Location
    Norway
    MS-Off Ver
    10
    Posts
    43

    Search for duplicates in two sheets, and delete row if duplicate

    Hello,

    I have a workbook with two sheets named "Kundeforinger" and "Mangler Foringer" with lots of data in both sheets. I have tried for a couple of hours to make this work now, with no luck.

    What I want to achieve:
    See if there are any duplicates in column "A" between the two sheets, and if a duplicate value is found, delete the entire row in the sheet named "Mangler Foringer"

    The code I have come up with works, sort of. Some of the cells are blank with no value, and I think my code stops the duplicate-searching here. It only deletes like 30 lines, instead of 300.

    Any help? Please feel free to suggest a different approach with the coding

    Here is the code I have so far
    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    08-17-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    132

    Re: Search for duplicates in two sheets, and delete row if duplicate

    Hi,

    Please attach a sample file for better understanding.

    Regards,

  3. #3
    Registered User
    Join Date
    06-26-2014
    Location
    Norway
    MS-Off Ver
    10
    Posts
    43

    Re: Search for duplicates in two sheets, and delete row if duplicate

    Please see attached sample workbook

    SampleFile.xlsm

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

    Re: Search for duplicates in two sheets, and delete row if duplicate

    Where are the duplicates in columns A on the sample attached? Are you sure you have attached the correct sample?

  5. #5
    Registered User
    Join Date
    06-26-2014
    Location
    Norway
    MS-Off Ver
    10
    Posts
    43

    Re: Search for duplicates in two sheets, and delete row if duplicate

    Column A in sheet MANGLER FØRING and column A in sheet KUNDEFØRINGER. If value in col A in the first sheet i mentioned exists in colunm A in the second sheet, delete entire row.

  6. #6
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Search for duplicates in two sheets, and delete row if duplicate

    I reiterate AB33's suggestion of maybe you attached a wrong, or unduly modified, workbook.

    Running your own code deletes just one line, nothing like the 30 you claim to delete, and far from the 300 or so that you claim exist.

    An independent code also found only one value in MANGLER FØRINGER ColA that's duplicated from KUNDEFØRINGER ColA

    That's the value 89579 on line 1519 in MANGLER FØRINGER ColA.


    Perhaps you should consider re-stating your request.

  7. #7
    Registered User
    Join Date
    06-26-2014
    Location
    Norway
    MS-Off Ver
    10
    Posts
    43

    Re: Search for duplicates in two sheets, and delete row if duplicate

    Well, it looks like it's the correct one i uploaded.

    Sheet Kundeføringer has 1581 rows in col A
    Sheet Mangler Føringer has 1767 rows in col A

    After the macro has run I should end up with the result in sheet "What i want"; 183 rows col A. These are the unique values.

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

    Re: Search for duplicates in two sheets, and delete row if duplicate

    As Kalak pointed out to you, there is a single duplicate on the sample. Could you tell us which lines are duplicates on your sample? Give us the row nos.

  9. #9
    Registered User
    Join Date
    06-26-2014
    Location
    Norway
    MS-Off Ver
    10
    Posts
    43

    Re: Search for duplicates in two sheets, and delete row if duplicate

    Sure! I'll list the first seven values, as listing all of them would

    Row in sheet Kundeføringer - Row in sheet mangler føringer - value
    971 - 11- 11101
    972 - 12 - 11115
    973 - 13 - 11197
    974 - 14 - 11216
    975 - 15 - 11245
    725 - 16 - 12276
    726 - 17 - 12340

  10. #10
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Search for duplicates in two sheets, and delete row if duplicate

    You might look at the following code and see if you agree with the logic behind it.

    Step through this code (using the attached file in your post#3), note what it does and what result it gives.

    Although both of your "11101" may look the same, according to VBA they are not the same. I haven't looked specifically at why they are different because you didn't request that.

    Your request was, as I understand, to use VBA to remove duplicates.
    VBA doesn't recognize your "duplicates", perhaps explaining the fruitless "couple of hours" as described in your opening post.

    It may be some of your "numbers" contain non-printing characters such as Chr(28), Chr(31), Chr(141), Chr(157) etc. in which case they may well look the same but are not. Maybe other reasons. I know nothing about how your data were generated. But you specifically asked about duplicates.
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    06-26-2014
    Location
    Norway
    MS-Off Ver
    10
    Posts
    43

    Re: Search for duplicates in two sheets, and delete row if duplicate

    stupid stupid me.. Sorry guys, there was some hidden characters. Ran this vba first and the duplicate remover then worked like a charm!
    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. [SOLVED] Delete,sum duplicates - duplicate based on multiple cell match
    By spikerush2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-04-2014, 01:53 PM
  2. Count duplicate rows then delete duplicates
    By dougf in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-26-2013, 04:13 PM
  3. Replies: 0
    Last Post: 11-15-2012, 06:47 AM
  4. Delete Duplicates based on 2 criteria 1st Acutal duplicate 2ND PREVIOUS DATE
    By xcruc1at3r in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-24-2011, 09:09 PM
  5. VBA- search duplicates, copy+paste row, delete row
    By Hammi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-10-2011, 01:02 PM

Tags for this Thread

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