+ Reply to Thread
Results 1 to 18 of 18

How To Consolidate Data From Different Sheets to One Summary Sheet

  1. #1
    Registered User
    Join Date
    07-03-2015
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    2010
    Posts
    11

    How To Consolidate Data From Different Sheets to One Summary Sheet

    Hi everyone,

    A new member here. I'm still trying to learn how to do macro and so I was wondering if anyone can help me do this exercise. I'm trying to create a macro where the summary workbook pulls the specific account balances of different branches. Each branch has its own workbook. I have attached the workbook per branch as well as what the Summary Sheet should look like per account summary. I've only attached two branch workbooks but I was actually hoping to use this for scenarios where there would be, say, more than 20 workbooks for consolidation. Any help would be much appreciated!
    Attached Files Attached Files
    Last edited by Lawliet918; 07-03-2015 at 03:02 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    re: How To Consolidate Data From Different Sheets to One Summary Sheet

    Hello Lawliet918,

    Welcome to the Forum!

    I haven't opened the zip file yet. Do you need a solution using Excel formulas, VBA macros, or either?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

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

    re: How To Consolidate Data From Different Sheets to One Summary Sheet

    You better could change the title.

    You want to make a consolidated file, from differant workbooks (instead of worksheets).

    1 workbooks contains several worksheets.
    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.

  4. #4
    Registered User
    Join Date
    07-03-2015
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    2010
    Posts
    11

    Re: How To Consolidate Data From Different Sheets to One Summary Sheet

    Quote Originally Posted by Leith Ross View Post
    Hello Lawliet918,

    Welcome to the Forum!

    I haven't opened the zip file yet. Do you need a solution using Excel formulas, VBA macros, or either?
    Hi Leith,

    Thanks for the response. I'm trying to learn VBA Macros so I'd appreciate it if the solution' through VBA macros.

  5. #5
    Registered User
    Join Date
    07-03-2015
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    2010
    Posts
    11

    Re: How To Consolidate Data From Different Sheets to One Summary Sheet

    Quote Originally Posted by oeldere View Post
    You better could change the title.

    You want to make a consolidated file, from differant workbooks (instead of worksheets).

    1 workbooks contains several worksheets.
    hi,

    you're right. sorry, my bad. will update the title.

  6. #6
    Registered User
    Join Date
    07-03-2015
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    2010
    Posts
    11

    Re: How To Consolidate Data From Different Sheets to One Summary Sheet

    Quote Originally Posted by oeldere View Post
    You better could change the title.

    You want to make a consolidated file, from differant workbooks (instead of worksheets).

    1 workbooks contains several worksheets.
    hi,

    would you know how to edit the title? i'm trying to look for the settings but couldn't seem to find it.

    thanks!

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

    Re: How To Consolidate Data From Different Sheets to One Summary Sheet

    I believe it is above your first question #1, in the toolbar

  8. #8
    Registered User
    Join Date
    07-03-2015
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    2010
    Posts
    11

    Re: How To Consolidate Data From Different Sheets to One Summary Sheet

    Quote Originally Posted by oeldere View Post
    I believe it is above your first question #1, in the toolbar
    that one only edits the post. but not the title. anyway, i'll edit the post to mean they're from different workbooks.

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: How To Consolidate Data From Different Sheets to One Summary Sheet

    Hello Lawliet918,

    In your Summary are you summing only the "Cash" entry from each branch?

    Do you want to create summaries for the other ledger accounts A/R, A/P, etc. for each branch also?

  10. #10
    Registered User
    Join Date
    07-03-2015
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    2010
    Posts
    11

    Re: How To Consolidate Data From Different Sheets to One Summary Sheet

    Quote Originally Posted by Leith Ross View Post
    Hello Lawliet918,

    In your Summary are you summing only the "Cash" entry from each branch?

    Do you want to create summaries for the other ledger accounts A/R, A/P, etc. for each branch also?
    Hi Leith,

    I just made Cash as an example. But I would definitely need to have separate worksheets for the other ledger accounts. So, in theory, I should have one ledger account summary per worksheet.

  11. #11
    Registered User
    Join Date
    07-03-2015
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    2010
    Posts
    11

    Re: How To Consolidate Data From Different Sheets to One Summary Sheet

    Quote Originally Posted by Leith Ross View Post
    Hello Lawliet918,

    In your Summary are you summing only the "Cash" entry from each branch?

    Do you want to create summaries for the other ledger accounts A/R, A/P, etc. for each branch also?
    please note that the account summary worksheet should still reflect the account balance per branch, and not a sum of the account balances of all branches.

  12. #12
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: How To Consolidate Data From Different Sheets to One Summary Sheet

    Hello Lawliet918,

    Okay, I think I have this working the way you want. Here is what the macro does.
    1. It looks for the branch files in the same folder where the Summary workbook is saved.
    2. Each workbook in the folder that has an xls, xlsx, or xlsm extension will opened. The workbook name less the extension is used as the branch name.
    3. "Sheet1" is examined starting at cell "A1". Each cell in the range starting at "A1" to the last non empty cell in column "A" is used as the worksheet name in the Summary workbook. If the worksheet by this name does not exist then it will be created using the "Template" worksheet in the Summary workbook. This sheet is hidden. The branch is added to the next empty row of the Summary worksheet along with the cash value. this process continues until all workbooks have been examined and copied.

    Summary Macro Code
    Please Login or Register  to view this content.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    07-03-2015
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    2010
    Posts
    11

    Re: How To Consolidate Data From Different Sheets to One Summary Sheet

    Quote Originally Posted by Leith Ross View Post
    Hello Lawliet918,

    Okay, I think I have this working the way you want. Here is what the macro does.
    1. It looks for the branch files in the same folder where the Summary workbook is saved.
    2. Each workbook in the folder that has an xls, xlsx, or xlsm extension will opened. The workbook name less the extension is used as the branch name.
    3. "Sheet1" is examined starting at cell "A1". Each cell in the range starting at "A1" to the last non empty cell in column "A" is used as the worksheet name in the Summary workbook. If the worksheet by this name does not exist then it will be created using the "Template" worksheet in the Summary workbook. This sheet is hidden. The branch is added to the next empty row of the Summary worksheet along with the cash value. this process continues until all workbooks have been examined and copied.

    Summary Macro Code
    Please Login or Register  to view this content.
    hi leith,

    thanks for the script.

    however, i ran the code and i'm getting run-time error '9': subscript out of range.

    would you know what's causing this?

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

    Re: How To Consolidate Data From Different Sheets to One Summary Sheet

    Could this be the reason?

    Please Login or Register  to view this content.

  15. #15
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: How To Consolidate Data From Different Sheets to One Summary Sheet

    Hello Lawliet918,

    There could be a variety of reasons for this error occurring. I made the code more robust and able to handle the more common reasons for this error.

    Jere is the modified macro code. The attached workbook has the changes.

    [b\Update Macro Code[/b]
    Please Login or Register  to view this content.
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    07-03-2015
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    2010
    Posts
    11

    Re: How To Consolidate Data From Different Sheets to One Summary Sheet

    Quote Originally Posted by oeldere View Post
    Could this be the reason?

    Please Login or Register  to view this content.
    Hi Leith,

    I tried running the updated code. There was no error but nothing happened.

    Is there any way I can do a VLOOKUP in macro so that I just basically have to VLOOKUP say "Cash" account and copy all the "Cash" account balances per branch to the summary workbook? And then pretty much do another macro to do a VLOOKUP on the other account balances and so on and so forth?

    The idea is that a branch may have a lot of ledger accounts but I will only be picking those I'm interested in (say Cash, Accounts Receivable, or Accounts Payable) and summarize all the branch balances in a separate workbook.
    Last edited by Lawliet918; 07-05-2015 at 07:14 PM.

  17. #17
    Registered User
    Join Date
    07-03-2015
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    2010
    Posts
    11

    Re: How To Consolidate Data From Different Sheets to One Summary Sheet

    Quote Originally Posted by Leith Ross View Post
    Hello Lawliet918,

    There could be a variety of reasons for this error occurring. I made the code more robust and able to handle the more common reasons for this error.

    Jere is the modified macro code. The attached workbook has the changes.

    [b\Update Macro Code[/b]
    Please Login or Register  to view this content.
    Okay. So I tried to see if I got some basic coding done right and so I did the subroutine below for Cash.

    It's kind of working as it copies the value of the account to a summary worksheet (i.e. BranchSummary.xlsx) but what I'm missing is how to run this subroutine automatically for like 20 workbooks each representing a distinct branch. Also, I need to have another column to indicate which branch did this account balance come from. I'm attaching four files to hopefully get you a better idea of what I want to do:

    The files are:

    1. Branch 1.xlsm - raw file for Branch 1
    2. Branch 2.xlsm - raw file for Branch 2
    3. BrandMaster.xlsx - what it looked like after running the subroutine below for both Branches
    4. BrandMasterShouldBe.xlsx - what it should look like and what I really wanted the format to be

    And here's the code I tried to write:

    *******

    Sub Cash()

    Dim LastRow As Integer, i As Integer, erow As Integer

    LastRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row

    For i = 1 To LastRow

    If Cells(i, 1) = "Cash" Then
    Range(Cells(i, 1), Cells(i, 2)).Select
    Selection.Copy

    Workbooks.Open Filename:="C:\Users\lsoriano006\Desktop\RIL_TEST\New folder\BrandMaster"
    Worksheets("Sheet1").Select
    erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

    ActiveSheet.Cells(erow, 1).Select
    ActiveSheet.Paste
    ActiveWorkbook.Save
    ActiveWorkbook.Close
    Application.CutCopyMode = False
    End If

    Next i
    End SubFor Data Consolidation_UPDATED.zip

  18. #18
    Registered User
    Join Date
    07-03-2015
    Location
    Winnipeg, Manitoba
    MS-Off Ver
    2010
    Posts
    11

    Re: How To Consolidate Data From Different Sheets to One Summary Sheet

    Quote Originally Posted by Leith Ross View Post
    Hello Lawliet918,

    There could be a variety of reasons for this error occurring. I made the code more robust and able to handle the more common reasons for this error.

    Jere is the modified macro code. The attached workbook has the changes.

    [b\Update Macro Code[/b]
    Please Login or Register  to view this content.
    Hi Leith,

    Just to give you a more realistic format of the reports per branch, I'm attaching the following:

    Note that the Cash Account Summary is just an example. I may have another Excel workbook for other significant accounts, say Accounts Receivable. But a subroutine for Cash should be able to provide precedent to other account subroutines.

    Thanks again!

    For Macro.zip

+ 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] Consolidate Data multiple sheets to a summary sheet
    By egchristensen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-01-2015, 02:04 PM
  2. Macro to PRIORITISE and CONSOLIDATE data across different sheets into summary sheet
    By JamesGoulding85 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-31-2013, 07:49 AM
  3. Replies: 20
    Last Post: 06-20-2013, 09:04 AM
  4. Replies: 20
    Last Post: 10-19-2012, 04:35 PM
  5. Consolidate data from rows in many sheets to summary sheet?
    By Dynelor in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-08-2008, 07:34 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