+ Reply to Thread
Results 1 to 34 of 34

How to combine data from multiple sheets into one?

  1. #1
    Registered User
    Join Date
    08-05-2014
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    42

    How to combine data from multiple sheets into one?

    I have an excel file that contains the outstanding customer accounts for multiple locations, each location on its own sheet. Some customers have outstanding accounts at more than one location. I would like to create a single sheet that combines the customers and their outstanding amounts from these, which I could then update monthly.

    For example, if customer John has $100 at location A, $50 at location c, and $200 at location F, on the sheet I want to create, it would show John as having $350 outstanding. How could I do this?

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,063

    Re: How to combine data from multiple sheets into one?

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? Please don't attach a picture of one (no-one will want to re-type all your stuff before starting).

    1. Make sure that your sample data are truly REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution is also shown (mock up the results manually).

    3. Make sure that all confidential information is removed first!!

    4. Try to avoid using merged cells. They cause lots of problems!

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: How to combine data from multiple sheets into one?

    Use PowerQuery (add-in for Ex2010) then PivotTable. I know nothing about your structure of data so I can't say more.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,209

    Re: How to combine data from multiple sheets into one?

    Try

    =SUMPRODUCT(SUMIF(INDIRECT("'" & Sheets &"'!A:A"),A2,INDIRECT("'" & Sheets &"'!B:B")))

    Sheets is a named range of all your sheet names.

    Customers are in column A

    Accounts in column B
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    08-05-2014
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    42

    Re: How to combine data from multiple sheets into one?

    I threw together an example that should be indicative of what I am working with (can't give actual customer data)
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,209

    Re: How to combine data from multiple sheets into one?

    See post #4.

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,209

    Re: How to combine data from multiple sheets into one?

    See attached

    in B2

    =VLOOKUP(A2,INDIRECT("'"&INDEX(Sheets,MATCH(1,--(COUNTIF(INDIRECT("'"&Sheets&"'!$A:$A"),A2)>0),0))&"'!$A:$B"),2,FALSE)

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.



    in C2

    =SUMPRODUCT(SUMIF(INDIRECT("'" & Sheets &"'!A:A"),A2,INDIRECT("'" & Sheets &"'!C:C")))

    For Column A, I simple copy/paste for each tab then "remove duplicates"
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    08-05-2014
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    42

    Re: How to combine data from multiple sheets into one?

    Quote Originally Posted by JohnTopley View Post
    See attached

    in B2

    =VLOOKUP(A2,INDIRECT("'"&INDEX(Sheets,MATCH(1,--(COUNTIF(INDIRECT("'"&Sheets&"'!$A:$A"),A2)>0),0))&"'!$A:$B"),2,FALSE)

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.



    in C2

    =SUMPRODUCT(SUMIF(INDIRECT("'" & Sheets &"'!A:A"),A2,INDIRECT("'" & Sheets &"'!C:C")))

    For Column A, I simple copy/paste for each tab then "remove duplicates"
    Thanks for all the replies John. Sorry I didn't get back to you, but I was sick. So this does a great job with the addition of the values, but is there an easier way to get the names besides just copy and pasting and removing the duplicates? We have 11 locations, with hundreds of customers at each location. It would be quite time consuming, and would leave room for error, if I were to have to go through the list each month. Is there a way to automatically have excel handle that?

  9. #9
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Cool Re: How to combine data from multiple sheets into one?

    is that what you want? (no formulas, no vba)
    (but it works with PowerQuery installed)

  10. #10
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,209

    Re: How to combine data from multiple sheets into one?

    I have a VBA-based solution BUT I would go with Sandy's PowerQuery solution (PQ not installed on my computer!).

  11. #11
    Registered User
    Join Date
    08-05-2014
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    42

    Re: How to combine data from multiple sheets into one?

    Quote Originally Posted by sandy666 View Post
    is that what you want? (no formulas, no vba)
    (but it works with PowerQuery installed)
    I appreciate the idea, but I only have excel 2007 to work with, so I don't have power query

    Quote Originally Posted by JohnTopley View Post
    I have a VBA-based solution BUT I would go with Sandy's PowerQuery solution (PQ not installed on my computer!).
    As I don't have power query, I would love to your about your VBA solution.

  12. #12
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: How to combine data from multiple sheets into one?

    so why you've 2010 in your profile? for Ex2010 is add-in PowerQuery from MS site

  13. #13
    Registered User
    Join Date
    08-05-2014
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    42

    Re: How to combine data from multiple sheets into one?

    switched jobs, didn't realize I still had that there, oops

  14. #14
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: How to combine data from multiple sheets into one?

    so change excel version in your profile for no more mistakes (and waste time )

  15. #15
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,209

    Re: How to combine data from multiple sheets into one?

    Please Login or Register  to view this content.
    This assumes the summary page is named "Total" as per your posted file. If it something else, change references to Total in the macro.

    The VBA collates and sorts unique entries for column A BUT uses the formulae in B2 and C2 (which must not be deleted). The VBA copies the formulae down the columns.

    NOTE: it uses ranges not tables.

    Click "RUN" button

  16. #16
    Registered User
    Join Date
    08-05-2014
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    42

    Re: How to combine data from multiple sheets into one?

    Quote Originally Posted by JohnTopley View Post
    Please Login or Register  to view this content.
    This assumes the summary page is named "Total" as per your posted file. If it something else, change references to Total in the macro.

    The VBA collates and sorts unique entries for column A BUT uses the formulae in B2 and C2 (which must not be deleted). The VBA copies the formulae down the columns.

    NOTE: it uses ranges not tables.

    Click "RUN" button
    Hi John and Sandy,

    I would like to thank you and apologize for being MIA. Please allow me to give you an update.

    I tried John's method, and it worked for about half the customers. I tried to figure out what was wrong but couldn't. During this time, I spoke to my managers about getting a new version of Excel, one with Power Query and other features I was missing. They said they would think about it. On the 22nd, I had an idea about what the problem would be, but something came up and I didn't get to post here that Friday. The following week, I had off for Thanksgiving, during which I got sick. I didn't get back to work until this week, and wouldn't you know it, my managers had ordered Office 2016, which got installed today. As I would like to understand both solutions, I am posting now a question to each of you:

    John:
    It appears that your formula is only searching for 4 cells undersheets. How do I expand this to cover 11 cells so I can search all locations? It appears that it is defined as an array or reference in a way I am not familiar.

    Sandy:
    I have never used Power Query before. Could you tell me how to use it for this? Could you provide me with some links to learn about it?

  17. #17
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: How to combine data from multiple sheets into one?

    You can read this: Getting Started with Get & Transform in Excel 2016 and this: Microsoft Power Query for Excel Help

    In your case it's a simple. (with your example)
    Load Loc A, Loc B, Loc C, Loc D to the Workbook Queries as connection then Append all Queries as new then load result query as connection
    Now you can load result query wherever you want

    How to....
    Click on Loc A range
    Data - From table
    Close&Load as connection
    the same for all Locs

    on the right side you'll see added queries as Table1, Table2 etc... you can change the names as you wish (I changed it to Loc A, Loc B etc...)

    right click on the first query, select Append, in new window you'll see first query on the right side so add second query, third query and fourth query from the left to the right
    now select all columns then Remove Duplicates and Sort Ascending if you want

    all in Query Editor !

    hope it's clear
    Last edited by sandy666; 12-08-2017 at 01:11 PM. Reason: with your example

  18. #18
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,209

    Re: How to combine data from multiple sheets into one?

    Minor change to VBA:

    Please Login or Register  to view this content.
    and change to named range "Sheets"

    =OFFSET(Total!$H$2,,,COUNTIF(Total!$H$2:$H$100,"?*"),1)

  19. #19
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: How to combine data from multiple sheets into one?

    btw. don't quote whole post in reply !

    Forum rule:

    Don't quote whole posts -- it's just clutter. If you are responding to a post out of sequence, limit quoted content to a few relevant lines that makes clear to whom and what you are responding

    For normal conversational replies, try using the QUICK REPLY box below.

  20. #20
    Registered User
    Join Date
    08-05-2014
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    42

    Re: How to combine data from multiple sheets into one?

    Quote Originally Posted by sandy666 View Post
    right click on the first query, select Append, in new window you'll see first query on the right side so add second query, third query and fourth query from the left to the right
    now select all columns then Remove Duplicates and Sort Ascending if you want
    Hi Sandy, thanks for the introduction to Power Query. This last part is where I run into trouble. It doesn't add the duplicate values left. So if a customer has amounts at two or three locations, it only displays the value from one location and removes the other value(s). I need each customer's total amount from all locations. Is there a way to do this Power Query.

    Quote Originally Posted by JohnTopley View Post
    and change to named range "Sheets"

    =OFFSET(Total!$H$2,,,COUNTIF(Total!$H$2:$H$100,"?*"),1)
    Hi John,

    so I repeated what I did before using the data from your new post, however I have problems. When I run the macro, it find customers and puts them in the sheet without a problem. However, it adds at the top of the list (cell A2) a customer "...", which is not in any location's list. Moreover, it doesn't populate columns B or C. What am I don't wrong? With regards to the =offset... formula that you gave me, where should I enter this? Upon copying your sheet into my file, the sheet range now is H1:H100, but I would like to know how to do this in the future.

    EDIT:
    Hey John, so upon closing and reopening Excel, the macro works without putting in "..." in A2. Additionally, the formulas in column B and C work. However, they only work if I click on each one, click the formula, and then CTRL+SHIFT+ENTER for column B and ENTER for column C. I can't drag the formulas down or double click the lower right corner, or I just get the value from the cell I started. Any ideas?
    Last edited by kb9omaaj; 12-09-2017 at 07:40 AM. Reason: update

  21. #21
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Cool Re: How to combine data from multiple sheets into one?


  22. #22
    Registered User
    Join Date
    08-05-2014
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    42

    Re: How to combine data from multiple sheets into one?

    Quote Originally Posted by sandy666 View Post
    check this one
    hi sandy,

    that file has everything right. But I tried to follow your steps (and I believe I did) with all the actual data. It was definitely pulling all the sheets together. However, when I get to the part "now select all columns then Remove Duplicates and Sort Ascending if you want" it removes the duplicate names while also removing the duplicate values. Could you maybe elaborate more on what needs to be done after append? Maybe there is something you instinctively know to do

  23. #23
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: How to combine data from multiple sheets into one?

    In last step don't remove duplicates but use Group by...
    see picture


    then sort by name if you wish

  24. #24
    Registered User
    Join Date
    08-05-2014
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    42

    Re: How to combine data from multiple sheets into one?

    Quote Originally Posted by sandy666 View Post
    In last step don't remove duplicates but use Group by...


    then sort by name if you wish
    Thanks, Sandy! I now have a working solution. Have a great weekend

  25. #25
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: How to combine data from multiple sheets into one?

    You are welcome

    If that takes care of your original question, & to say Thanks, please click on Add Reputtion (bottom left corner of the post of the person(s) who helped you)
    then select Thread Tools from the menu (top right corner of your thread) and mark this thread as SOLVED.
    If you did it already - ignore it.
    Thank you.

  26. #26
    Registered User
    Join Date
    08-05-2014
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    42

    Re: How to combine data from multiple sheets into one?

    it won't let me give you any more reputation than I already have, sorry. I'm going to wait for John's response before I mark this as solved, just so I know multiple ways of doing this in the future

  27. #27
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: How to combine data from multiple sheets into one?

    No problem
    You can add rep to John what allow you to add rep to me

  28. #28
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,209

    Re: How to combine data from multiple sheets into one?

    There is no need to drag the formulas: the VBA copies the formulas in B2 & C2 to the cells in B and C.

    Simply ensure the named range "Sheets" has all the required tabs and then click "RUN".

  29. #29
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,209

    Re: How to combine data from multiple sheets into one?

    Please Login or Register  to view this content.
    Highlighted code creates "Sheets" list for you

  30. #30
    Registered User
    Join Date
    08-05-2014
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    42

    Re: How to combine data from multiple sheets into one?

    Quote Originally Posted by JohnTopley View Post

    Highlighted code creates "Sheets" list for you
    I have tried copying your total sheet into my excel file and my other 11 sheets into your excel file. Unfortunately, it gathers all the names and removes duplicates, but it doesn't change the customer number or outstanding. Or rather, it sets all customer numbers to 13296 and sets all outstandings to 850. If I click on a customer number cell, click the formula, and hit CTRL+SHIFT+ENTER then the cell gets the right customer number. If I click on a customer number cell, click the formula, and hit ENTER then the cell gets the outstanding.

    What's going wrong? Does it matter that one location has alpha numeric customer numbers?

  31. #31
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,209

    Re: How to combine data from multiple sheets into one?

    It always works for me: alpha numeric customer numbers makes no difference.

    I think the problem is "Calculation Options" (in "Formulas") is set to "Manual": set to "Automatic".

  32. #32
    Registered User
    Join Date
    08-05-2014
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    42

    Re: How to combine data from multiple sheets into one?

    You were right, that wasn't enabled.

    You know what, that's the darndest thing. I know I had already set that and disabled editing directly in the cells. For some reason, editing directly in the cells was still disabled bout this wasn't set to automatic. Gremlins in officde 2016?

    Anyway, thanks again for all your help!

  33. #33
    Registered User
    Join Date
    08-05-2014
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    42

    Re: How to combine data from multiple sheets into one?

    Quote Originally Posted by kb9omaaj View Post
    Hi Sandy, thanks for the introduction to Power Query. This last part is where I run into trouble. It doesn't add the duplicate values left. So if a customer has amounts at two or three locations, it only displays the value from one location and removes the other value(s). I need each customer's total amount from all locations. Is there a way to do this Power Query.



    Hi John,

    so I repeated what I did before using the data from your new post, however I have problems. When I run the macro, it find customers and puts them in the sheet without a problem. However, it adds at the top of the list (cell A2) a customer "...", which is not in any location's list. Moreover, it doesn't populate columns B or C. What am I don't wrong? With regards to the =offset... formula that you gave me, where should I enter this? Upon copying your sheet into my file, the sheet range now is H1:H100, but I would like to know how to do this in the future.

    EDIT:
    Hey John, so upon closing and reopening Excel, the macro works without putting in "..." in A2. Additionally, the formulas in column B and C work. However, they only work if I click on each one, click the formula, and then CTRL+SHIFT+ENTER for column B and ENTER for column C. I can't drag the formulas down or double click the lower right corner, or I just get the value from the cell I started. Any ideas?
    Hi Sandy, I hope you're doing well. The file had been working great, however, we are adding a new location and now there are problems. Here is what I am doing:

    1. I select the locations tab
    2. I go to the Data ribbon and select "From Table" which is in the get and transform group.
    3. The query editor opens, I change the name to the location, and click "Close & Load"
    4. The excel file works for a while, but then I get an error that "Initialization of the data source failed."
    5. If I click ok (the only other option other than to click x on the error box), I can see that the data stops at line 35 (but there should be over 100). I have triedd this repeatedly and it is always in the middle of this line.

    Am I forgetting something? What could the error be?

  34. #34
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: How to combine data from multiple sheets into one?

    Attach file with this error

    btw. You cannot change header in source after load table. If you want to change it you must change it everywhere in queries/ Open Advanced Editor then look for old name and change it to new name.
    But you can change header(s) in query table(s)
    Last edited by sandy666; 02-08-2018 at 04:18 PM.

+ 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] Combine Data from Multiple Sheets into one Sheet
    By billykiller05 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-30-2016, 05:14 PM
  2. Combine data in multiple sheets to one sheet
    By RDevi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-10-2016, 10:44 AM
  3. Combine data from multiple sheets into one
    By SuperErizzle in forum Excel General
    Replies: 1
    Last Post: 06-11-2013, 10:51 PM
  4. Combine data from multiple sheets with conditions
    By luckyk in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-28-2012, 11:20 AM
  5. Combine similar data from multiple sheets
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-07-2010, 07:39 PM
  6. Combine Data from multiple sheets
    By samfarrugia in forum Excel General
    Replies: 7
    Last Post: 10-02-2009, 11:41 AM
  7. combine data from multiple sheets
    By Roxypup in forum Excel General
    Replies: 2
    Last Post: 04-07-2006, 02:45 AM

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