+ Reply to Thread
Results 1 to 52 of 52

Combine multiple spreadsheets, using common columns and combining any duplicates

  1. #1
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Combine multiple spreadsheets, using common columns and combining any duplicates

    Hi, I am trying to figure out how to combine the spreadsheets on the attached workbook into 1. In the example attached I only included 1 or 2 items from each spreadsheet because I needed to change some info to attach it here. But,
    the columns data in the rows on each spreadsheet can range from 0 to a couple thousand. I need for the columns with the same headings to be all under the same headings.. as it is now each spreadsheet may have the column names in different areas, and each one may have a column unique to just that sheet. So, the final spreadsheet would need to include all of the columns listed from each report (1 of each).. the other variable here is column A, the file number, if the file number can be repeated in the spreadsheets, but I need for the combined spreadsheet to only list each file once (and adding the data from that particular sheet) Some sheets do not have data, for that particular day, in that case, cell 2A = "No matching account found" - and that data does not need to be transferred.

    Any help would be very much appreciated, thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Hi G1983

    Could you expand on this a bit...
    the other variable here is column A, the file number, if the file number can be repeated in the spreadsheets, but I need for the combined spreadsheet to only list each file once (and adding the data from that particular sheet)
    For example, File 2222 appears in Mail Review and Estate Claim Review. The only common info is the File Number and Debtor State. What do you expect to see?

    Row\Col
    A
    B
    C
    D
    E
    F
    G
    H
    I
    1
    Fileno Debtor State Client Name Plaintiff Name Attorney Name Mail Recvd Mail Reviewed Days Mail Review Late Status Description
    2
    2222
    NC Client Name222 Plaintiff Name 22 Melissa 04/07/2016
    1
    Service of Complaint
    3
    4
    Fileno Client Name Plaintiff Name Debtor State Need Estate Review Date Days Estate Review Needed Status Description
    5
    2222
    CNAME343 PNAME432 NC
    3/3/2015
    105
    XYZ
    6
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

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

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    BG1983,

    Here's how I read your problem.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368
    Hi, yes, that is the only common values, so, it would be one
    Row with both of those dates filled in on those two columns
    .. while the rest of the columns are blank...

  5. #5
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368
    Jindon, i am not in front of a PC right now but look
    Forward t giving this a shot. You have helped me
    Tremendously a couple times! You see to be great at
    Solving these problems extremely efficiently so i
    Was wondering if you taught any courses, or, how you
    Learned... the style of your coding is awesome and something
    Id like to understand a bit more. Again, truly appreciate
    Your help and will let you know how this code works for
    My purposes

  6. #6
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Okay - So I think this is what I needed. But, something I didn't think of is that it would be great if we made the name of each tab a column in the "Summary Report" Sheet - Preferably Column A.

    Also, something I just noticed is that the columns "Assigned Attorney" and "Attorney Name" are separated - which is correct based on my description since they are not the same name. But, if possible, they should be treated as the same - which would be "Assigned Attorney"
    The same logic would apply to the columns "Attorney Review Date" and "Attorney Reviewed Date"

    Thanks again for your help!!

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

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    The I need to see the result that you want in workbook.

    Just 2 or 3 examples clearly shows the logic will be enough...

  8. #8
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Sure - Here you go. FYI - I changed the fill of the columns that are repeated but with different names to red so that they stand out... you can ignore the fill otherwise
    Attached Files Attached Files

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

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Not sure if this is how you wanted...
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Just about! Everything looks good but when I ran this on the actual data the "Current Bucket" column came out all blank. (This is the one that should be named as the tab that the info came from - and if the file number is repeated.... where you have combined the data so that is is only on 1 row.. its fine that the second "current bucket" overwrites the first "current bucket" in that column..)

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

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Can you just add one line
    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    You're my hero man. Looks great! Thank you for your help!

  13. #13
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    So I am attempting to use this for all workbooks in a folder now... Do you mind taking a glance at the below and see where I am going wrong please?

    Please Login or Register  to view this content.

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

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Untested.
    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Hey, so I couldnt get this to finish with the full number of workbooks I had in the folder.. i let it run for like 45 minutes but still hadnt finished. But, I used just a couple workbooks and it looks like it worked.

    The one last thing I'd like to have happen is for the workbook name that the data came from be the value of a column A. So, all tabs in "Workbook1" would have a value of "Workbook1" in column A of the Summary Report tab of the workbook I ran the report from. Then column B would be file number... and C would be Current Bucket

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

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    No sure, if this works
    Please Login or Register  to view this content.

  17. #17
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Thanks, going to try that now.. it takes a while to run. Out of curiosity - Do you think that this would work better for me if I first had all of the tabs from each workbook transferred onto one workbook... and then ran your portion of the code? Instead of doing it all at once?

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

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Fully depends on how many workbooks/worksheets and # of rows in one sheet.

    If you could copy all the worksheets in all the workbooks, it might be better...

  19. #19
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Well, the workbook I provided at the beginning as an example likely has the most worksheets out of all of them.. there are around 17 workbooks total... the total "fileno" population (all files in our inventory) is around 100,000.. so, as long as there are no duplicates at the end there should be around that many rows. The most rows in 1 worksheet is around 10,000 I believe.

    Just trying to figure out the best way to get all of the data from each workbook, by sheet... (including both worksheet name and workbook name for all) into one table...

  20. #20
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Also, was thinking that it would run smoother if I changed all of the files from xlsx to xlsb...

  21. #21
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    So when I tried this one it immediately returned with a message of "no data"

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

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    That means every worksheets in workbooks may

    Any one/both of header "FileNo" or/and "Client Name" is missing. or A2 is ""NO MATCHING"....

  23. #23
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Did you set it up so that it always had to have both the Fileno and client name in there? These have fileno but not client name..

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

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    My code is assuming that "FileNo" and "Client Name" makes unique key...

  25. #25
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    The FileNo alone is unique

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

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Then try change to
    Please Login or Register  to view this content.

  27. #27
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    hmm... now it says runtime error 13 - type mismatch

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

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    OOps
    change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  29. #29
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Okay, so aside from FileNo not being in column A, that worked! So, going back to the workbooks, adding all worksheetes to 1 workbook... I just used the recorder and selected all sheets, then copied over to other workbook... like below.. is this the best way to do that? And would there be a way to add the workbook name anywhere in there? Sorry, I promise I am almost done bothering you!

    Please Login or Register  to view this content.

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

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Does that mean all of the worksheets in all the workbook?

  31. #31
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    The above? That was only for 1 workbook. But yes, I am trying to get all of the worksheets for all of the workbooks onto 1 workbook and then combine them into 1 worksheet like your code does

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

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    How about
    Please Login or Register  to view this content.

  33. #33
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Hmm, stopped after 1 tab with error "subscript out of range"

  34. #34
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Dang, its because both of the tabs are named the same thing.. which I think may be the only time that happens... can a 2 be added if there already is one?

  35. #35
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Nevermind.. I removed that workbook and re-ran it and it threw the same error

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

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Missed one line,
    It should copy regardless of same worksheets.
    It shoud rename something like "xxx(1)" "xxx(2)" and it is working here.
    Please Login or Register  to view this content.

  37. #37
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Same error :/

  38. #38
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    I had added the exit_sub: previously..

  39. #39
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Okay - I got it. My open workbook was starting on sheet1 - not 2.. so I changed that and we are good

  40. #40
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Thanks again for your help man!

  41. #41
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    So there are 240 worksheets haha... whats the best way to delete all of these after they have been added to the new sheet? One at a time or all at once at the end?

  42. #42
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    This I assume...?

    Please Login or Register  to view this content.

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

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Something like
    Please Login or Register  to view this content.

  44. #44
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Gotcha. Okay. Well, I tried to run it on the 240 tabs and got an "overflow" error.. so, going to take a break for a bit and think things through... i assume overflow would just be because its too much.

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

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    I guess so and my next reply will be tomorrow.

  46. #46
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    haha - again, I appreciate your help man - Have a good one

  47. #47
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Hey, so I know this is off topic, but wanted to borrow your genious to glance at this for a second if you had a minute... this is a macro that runs off of a refresh-able spreadsheet. If the user selects this macro, it will pull up the date 2 input boxes for the date range.. then it filters the table.. then copies the data over to a new spreadsheet called "Who's On First Data" then it cleans up that spreadsheet a little bit before creating a new tab with a pivot table called "Who's On First" -- the pivot table is the days of the week that the user selected, with everything that is not blank filled with the color red.

    My problem is that it works once.. then it wont work again... after deleting the tabs.. etc.. have you seen anything like that before?


    Please Login or Register  to view this content.

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

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    BG1983,

    Sorry I was away.

    It is too hard to comment without a workbook...

  49. #49
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    Hi Jindon - See attached workbook. Quesiton for you - How can we edit the code you have here to just compare the two worksheets attached and both highlight the differences/Move them over to a new sheet? Also, if there is a number in column A on sheet 1 that is not in column A on sheet 2, then highlight those a different color.. So, basically - the comparison is by column A values and then finding the corresponding column header (row1) and comparing the corresponding intersecting cell. I think this code you have made here pretty much does just that and could be tweaked pretty quickly to accomplish this...**note that the lookup values of column A will not always be in this format, it could be various different formats so it just needs to be exact match.. Also - although this data is in 1 workbook Id like to have it compare 2 workbooks, 1 would be "ThisWorkbook" and the other one would be user defined via a prompt to open file from location
    Attached Files Attached Files
    Last edited by BG1983; 06-02-2016 at 10:56 AM.

  50. #50
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    any luck with this?

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

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates

    BG1983

    Still not in good condition, but how your last question related to your original?
    I think you should better open a new thread.

  52. #52
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Combine multiple spreadsheets, using common columns and combining any duplicates


+ 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. Replies: 2
    Last Post: 01-13-2014, 10:52 AM
  2. Combining common columns from two worksheets
    By Keiras12 in forum Excel General
    Replies: 1
    Last Post: 04-11-2011, 07:25 PM
  3. Combining Multiple Spreadsheets (semi-duplicates)
    By gtramer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-25-2011, 07:42 PM
  4. Merge multiple spreadsheets with common field
    By sbarry50 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-19-2010, 11:42 AM
  5. Common problem combining multiple sheets?
    By db8r in forum Excel General
    Replies: 3
    Last Post: 07-30-2009, 08:54 PM
  6. Common User Form for Multiple Spreadsheets
    By IanBrown in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-20-2007, 03:42 AM
  7. Combine 2 spreadsheets w/1 common column of data, text and number
    By Ginger in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-26-2006, 06:50 PM
  8. [SOLVED] How do I combine rows, combining duplicates as well as concatenati
    By Donovan Panone in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-25-2005, 03:06 PM

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