+ Reply to Thread
Results 1 to 11 of 11

Help fixing vba to copy excel duplicates to new sheet

  1. #1
    Registered User
    Join Date
    01-07-2021
    Location
    Seychelles
    MS-Off Ver
    2016
    Posts
    6

    Help fixing vba to copy excel duplicates to new sheet

    Hi all, I am trying to fix a piece of vba code to copy duplicate rows based on a chosen range and copy all the duplicates to a new excel sheet.

    So far the code is working almost to my expectations, except that the code copies additional rows with blank cells. Below is an illustration of my issue:

    The picture below shows the data sample that i want to check for duplicate rows based on. When i run the macro i will be asked to select my range so i will highlight A1 to C5.

    1.png

    The following result below is then copied to the new sheet. The rows highlighted in green are the correct duplicates i expected but additional ones that i highlighted in red appears.

    2.png

    Here is the code and i have also attached a sample of the excel file with the macro:

    Please Login or Register  to view this content.
    Attached Files Attached Files

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

    Re: Help fixing vba to copy excel duplicates to new sheet

    Can you upload a workbook showing your desired result?

  3. #3
    Registered User
    Join Date
    01-07-2021
    Location
    Seychelles
    MS-Off Ver
    2016
    Posts
    6

    Re: Help fixing vba to copy excel duplicates to new sheet

    Jindon thanks for replying, I have attached an excel file at the bottom of my original post which you can download. My desired results are to expect the duplicates highlighted in green in the picture above and not the additional ones highlighted in red.

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

    Re: Help fixing vba to copy excel duplicates to new sheet

    Select A1:C5 from Sheet1 the the code paste to a new sheet.
    The result are exactly the same as Sheet48, that is originally attached.

    So what's the problem?

  5. #5
    Registered User
    Join Date
    01-07-2021
    Location
    Seychelles
    MS-Off Ver
    2016
    Posts
    6

    Re: Help fixing vba to copy excel duplicates to new sheet

    The problem is that there additional rows that are copied to the new sheet which are not row duplicates. I have show clearly above that the green rows i highlighted are the desired duplicates i expected and that the ones highlighted in red are additional which i do not want. I have attached another sample file in this reply which has a sheet called desired results. If you look at row 4 and 5 in the source sheet only these are row duplicates, so i expect the code to see these 2 rows as the duplicates only
    Attached Files Attached Files
    Last edited by ymk10; 01-07-2021 at 05:08 AM.

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

    Re: Help fixing vba to copy excel duplicates to new sheet

    So you want to extract only duplicates.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-07-2021
    Location
    Seychelles
    MS-Off Ver
    2016
    Posts
    6

    Re: Help fixing vba to copy excel duplicates to new sheet

    Yes only duplicates. Regardless whether they appear twice, 3 times or more it should be copied. Ill give your code a test now. Thanks jindon, ill get back to you.

  8. #8
    Registered User
    Join Date
    01-07-2021
    Location
    Seychelles
    MS-Off Ver
    2016
    Posts
    6

    Re: Help fixing vba to copy excel duplicates to new sheet

    Jindon you are a genius brother it works exactly as expected. Thanks a lot for your help!

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

    Re: Help fixing vba to copy excel duplicates to new sheet

    You are welcome and thanks for the rep.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

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

    Re: Help fixing vba to copy excel duplicates to new sheet

    ymk10,

    I just realized that the result array should be isolated from the original array, just in case.
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    01-07-2021
    Location
    Seychelles
    MS-Off Ver
    2016
    Posts
    6

    Re: Help fixing vba to copy excel duplicates to new sheet

    Ah I see, noted and many thanks again!

+ 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. Job Fixing Excel Sheet made on PC to operate on Mac
    By nlorenz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-18-2016, 09:55 AM
  2. [SOLVED] Need help with fixing duplicates
    By obionenairobi in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 03-13-2015, 08:44 AM
  3. [SOLVED] Automatic date change in excel sheet print out? Needs fixing
    By bob07904 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-29-2014, 01:22 PM
  4. Fixing Object from moving in protected excel sheet
    By Dawn Taylor in forum Excel General
    Replies: 0
    Last Post: 12-03-2013, 10:12 PM
  5. [SOLVED] Fixing Removing Duplicates Code Syntax
    By Panda2000 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-18-2012, 07:18 PM
  6. Copy Duplicates to new sheet
    By faisalS in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-01-2011, 05:52 PM
  7. fixing a mistake on excel sheet- #REF!
    By pattieayre in forum Excel General
    Replies: 5
    Last Post: 05-26-2008, 02:03 AM

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