+ Reply to Thread
Results 1 to 7 of 7

Duplicate rows based on condition

  1. #1
    Registered User
    Join Date
    09-29-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    91

    Duplicate rows based on condition

    I am working on providing reports on data. However, the data is not clean and has errors. In the following spreadsheet, every ID has to have one Book ID associated with it. However, multiple entries have also been recorded. I am trying to identify rows with multiple entries of IDs and then duplicate the row and record just one ID. For eg, If there is an ID with two Book-IDs, then that row has to be duplicated once and the Book ID field should have only the second Book-ID. I have provided sample results as well.

    I tried writing a macro but it does not seem to be working out. Plz help.

    Thanks,
    Booo
    Attached Files Attached Files

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Duplicate rows based on condition

    Hi booo,

    Does this do what you are looking for? I've assumed that the IDs will always be seperated with commas.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-29-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: Duplicate rows based on condition

    Kyle, That was just amazing. But I am completely new to Macros and would be very grateful if you could exlpain the code, atleast briefly. All the commands are completely foreign to me.

    Many Thanks,
    Booo

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Duplicate rows based on condition

    I've added a lot of notes to the code, but if not clear you might be better off reading up on loops and arrays as you will use them a lot, if you've got any specific questions though let me know

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-29-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: Duplicate rows based on condition

    Kyle,

    I am extremely thankful for the effort. You are awesome.

    Booo

  6. #6
    Registered User
    Join Date
    09-29-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: Duplicate rows based on condition

    There is only one small problem. The sample data that I have provided has just 3 columns but the real time data I deal with has about 100 columns.

    I;m sure that there is an easier way to insert data.

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Duplicate rows based on condition

    Can you upload a sample workbook with the data laid out as it is in your actual workbook?

    I'll have a look at it and come back to you.

+ 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