+ Reply to Thread
Results 1 to 28 of 28

Combine & Merge Data from Multiple Rows

  1. #1
    Registered User
    Join Date
    06-30-2016
    Location
    Karachi, Pakistan
    MS-Off Ver
    MS Office 2019
    Posts
    38

    Combine & Merge Data from Multiple Rows

    Hi,

    I need help in merging and combining data from multiple rows and deleting duplicates. I have multiple number of contact information (rows) against single e-mail address (primary value). I need Excel to look for first row of primary value (email address) and fill out missing values (columns) from other rows. So the first row of contact information would be my key record, complete this record from other rows and delete duplicate/other rows.

    Please see the attached file for better understanding of raw data and example output. Example.xlsx

    Thanks
    Last edited by rockstar1989; 08-22-2022 at 01:19 PM.

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Combine & Merge Data from Multiple Rows

    Probably I can't help you with your question.

    Cook Woods is in Oregon and NY.

    In the result you refer tot Oregon.

    What is the criteria for that?



    Another tought.

    Is there no other data where you can pull all information instead of combining data.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Combine & Merge Data from Multiple Rows

    Hi. I show you one way:

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

  4. #4
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,377

    Re: Combine & Merge Data from Multiple Rows

    One more variant

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-30-2016
    Location
    Karachi, Pakistan
    MS-Off Ver
    MS Office 2019
    Posts
    38

    Re: Combine & Merge Data from Multiple Rows

    This looks wonderful. I have data in 22 columns (A to V) and the key value (email address) is in column D. How do I edit this code as per these specifications? Also I want data to be extracted in Sheet2 range A1.

    Many thanks for your help.

  6. #6
    Registered User
    Join Date
    06-30-2016
    Location
    Karachi, Pakistan
    MS-Off Ver
    MS Office 2019
    Posts
    38

    Re: Combine & Merge Data from Multiple Rows

    Quote Originally Posted by beyond Excel View Post
    Hi. I show you one way:

    Please Login or Register  to view this content.
    This looks wonderful. I have data in 22 columns (A to V) and the key value (email address) is in column D. How do I edit this code as per these specifications? Also I want data to be extracted in Sheet2 range A1.

    Many thanks for your help.

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

    Re: Combine & Merge Data from Multiple Rows

    Please Login or Register  to view this content.
    Last edited by jindon; 08-22-2022 at 09:51 PM. Reason: Changed the code as I misread the problem.

  8. #8
    Registered User
    Join Date
    06-30-2016
    Location
    Karachi, Pakistan
    MS-Off Ver
    MS Office 2019
    Posts
    38

    Re: Combine & Merge Data from Multiple Rows

    Quote Originally Posted by jindon View Post
    Please Login or Register  to view this content.
    This isn't copying missing data from other rows. For example it has not copied Title (column E) and Contact (column I) from other rows.

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

    Re: Combine & Merge Data from Multiple Rows

    Should,

    I changed the code as I realzed I misread the problem, so you may using the code one before I changed.

  10. #10
    Registered User
    Join Date
    06-30-2016
    Location
    Karachi, Pakistan
    MS-Off Ver
    MS Office 2019
    Posts
    38

    Re: Combine & Merge Data from Multiple Rows

    Quote Originally Posted by beyond Excel View Post
    Hi. I show you one way:

    Please Login or Register  to view this content.
    Yes sure. I just want this code to be changed as per these specifications: Data in 22 columns (A to V), Key value (email address) is in column D, Data to be extracted in Sheet2 range A1.

  11. #11
    Registered User
    Join Date
    06-30-2016
    Location
    Karachi, Pakistan
    MS-Off Ver
    MS Office 2019
    Posts
    38

    Re: Combine & Merge Data from Multiple Rows

    Quote Originally Posted by JEC. View Post
    One more variant

    Please Login or Register  to view this content.
    This one also works fine.
    I just want this code to be changed as per these specifications: Data in 22 columns (A to V), Key value (email address) is in column D, Data to be extracted in Sheet2 range A1.

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

    Re: Combine & Merge Data from Multiple Rows

    Quote Originally Posted by jindon View Post
    Should,

    I changed the code as I realzed I misread the problem, so you may using the code one before I changed.
    ...........
    Attached Files Attached Files
    Last edited by jindon; 08-22-2022 at 11:16 PM. Reason: file attacched as an evidence.

  13. #13
    Registered User
    Join Date
    06-30-2016
    Location
    Karachi, Pakistan
    MS-Off Ver
    MS Office 2019
    Posts
    38

    Re: Combine & Merge Data from Multiple Rows

    Quote Originally Posted by jindon View Post
    ...........
    Seems good. But the code is still running after 15+ minutes on my original file of 82k rows. Is there any faster solution for this?

  14. #14
    Registered User
    Join Date
    06-30-2016
    Location
    Karachi, Pakistan
    MS-Off Ver
    MS Office 2019
    Posts
    38

    Re: Combine & Merge Data from Multiple Rows

    Quote Originally Posted by jindon View Post
    ...........
    30 minutes and the code has still not responded

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

    Re: Combine & Merge Data from Multiple Rows

    See if this is faster.
    Please Login or Register  to view this content.
    Or
    Please Login or Register  to view this content.
    Last edited by jindon; 08-23-2022 at 01:36 AM.

  16. #16
    Registered User
    Join Date
    06-30-2016
    Location
    Karachi, Pakistan
    MS-Off Ver
    MS Office 2019
    Posts
    38

    Re: Combine & Merge Data from Multiple Rows

    Quote Originally Posted by jindon View Post
    See if this is faster.
    Please Login or Register  to view this content.
    Or
    Please Login or Register  to view this content.
    Thanks for your help. The first code gave "Type Mismatch" error on line 8 highlighting this > If a(i, ii) <> "" Then

    The second code gave result within 5 seconds but some values are wrongly inputted. Two rows of same email address had no values in title column but the output result had title inputted

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

    Re: Combine & Merge Data from Multiple Rows

    If type mismatch, you may have error value somewhere.
    Please Login or Register  to view this content.
    Can not replicate the "wrong result".
    Please Login or Register  to view this content.
    Last edited by jindon; 08-23-2022 at 02:11 AM. Reason: typo

  18. #18
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Combine & Merge Data from Multiple Rows

    @rockstar1989

    Please don't quote whole text, just the part you refer to.

    If you are responding out of sequence, it is usually enough just to mention the helper's user name (e.g @Oeldere).

  19. #19
    Registered User
    Join Date
    06-30-2016
    Location
    Karachi, Pakistan
    MS-Off Ver
    MS Office 2019
    Posts
    38

    Re: Combine & Merge Data from Multiple Rows

    @jindon

    Both codes are working but the results aren't fine. Check sample file attached. I have highlighted one of the wrong results. Column J and K are blank but the result gives values in column J and K.
    Attached Files Attached Files

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

    Re: Combine & Merge Data from Multiple Rows

    OK, change to
    Please Login or Register  to view this content.

  21. #21
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Combine & Merge Data from Multiple Rows

    Quote Originally Posted by rockstar1989 View Post
    This looks wonderful. I have data in 22 columns (A to V) and the key value (email address) is in column D. How do I edit this code as per these specifications? Also I want data to be extracted in Sheet2 range A1.
    I show you the small adjustment:
    Attached Files Attached Files

  22. #22
    Registered User
    Join Date
    06-30-2016
    Location
    Karachi, Pakistan
    MS-Off Ver
    MS Office 2019
    Posts
    38

    Re: Combine & Merge Data from Multiple Rows

    @jindon

    Almost there. Please check attached file, just two issues:

    - Yellow highlighted: when there is a value in first row then it should not replace it with the value in second row because first row data is the most recent one so I have to keep it.
    - Green highlighted: when there isn't any value in first row, it should take from the second row but this one has taken values from the third row.

    Thanks again for your help!
    Attached Files Attached Files

  23. #23
    Registered User
    Join Date
    06-30-2016
    Location
    Karachi, Pakistan
    MS-Off Ver
    MS Office 2019
    Posts
    38

    Re: Combine & Merge Data from Multiple Rows

    @beyond Excel

    This one is taking too long to perform. I waited for 15 minutes but it wasn't responding.

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

    Re: Combine & Merge Data from Multiple Rows

    try change to this
    Please Login or Register  to view this content.
    EDIT typo
    And another typo...
    Last edited by jindon; 08-23-2022 at 07:02 AM.

  25. #25
    Registered User
    Join Date
    06-30-2016
    Location
    Karachi, Pakistan
    MS-Off Ver
    MS Office 2019
    Posts
    38

    Re: Combine & Merge Data from Multiple Rows

    @jindon

    This one is perfect! Thank you so much!

  26. #26
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Combine & Merge Data from Multiple Rows

    Quote Originally Posted by rockstar1989 View Post
    ... on my original file of 82k rows.
    My bad!... I hadn't read this detail about the 82K rows. Let's go for my last proposal:

    Please Login or Register  to view this content.
    Last edited by beyond Excel; 08-23-2022 at 01:26 PM.

  27. #27
    Registered User
    Join Date
    06-30-2016
    Location
    Karachi, Pakistan
    MS-Off Ver
    MS Office 2019
    Posts
    38

    Re: Combine & Merge Data from Multiple Rows

    @beyond Excel

    It gives Type Mismatch error on this line > If Mat2(k, j) = "" Then

  28. #28
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Combine & Merge Data from Multiple Rows

    Quote Originally Posted by rockstar1989 View Post
    @beyond Excel

    It gives Type Mismatch error on this line > If Mat2(k, j) = "" Then
    That's because you have something "weird" in some cell: Is there any way I can see your real data?...

+ 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. Combine/merge duplicate rows but retain unique data
    By Natalie Hanlon in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-02-2015, 01:22 PM
  2. Merge Duplicate Rows and Combine Unique Data
    By rickt33 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-08-2015, 09:12 PM
  3. Replies: 4
    Last Post: 09-26-2013, 04:15 PM
  4. Merge duplicate rows and combine data in some of the same columns
    By Ken.runciman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-23-2013, 11:43 PM
  5. Replies: 1
    Last Post: 10-22-2012, 11:09 PM
  6. Replies: 1
    Last Post: 09-13-2011, 04:33 PM
  7. Macro for VLookup: Combine/Merge Data and Insert/Duplicate Rows
    By choofrfreoer in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-08-2011, 04:10 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