Results 1 to 6 of 6

Thread: [RESOLVED] Summing multiple spreadsheets into 1

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2008
    Location
    U.K.
    Posts
    65

    Resolved [RESOLVED] Summing multiple spreadsheets into 1

    I have a number of spreadsheets in a folder which are all exactly the same called test1.xls, test2.xls, test3.xls etc.

    Within each spreadsheet are 3 tabs. All the tabs are identically named and the first tab is replicated throughout all the spreadsheets.

    What I am trying to do (but failing miserably) is to find a way of summing the first tab in each spreadsheet into a single tab on a central spreadsheet.

    For Example:

    test1.xls (TAB1)

    Column A Column B Column C Column D
    19 22 01 16
    18 21 12 32

    test2.xls (TAB1)

    Column A Column B Column C Column D
    32 25 41 01
    10 05 12 02

    test2.xls (TAB1)

    Column A Column B Column C Column D
    05 21 49 17
    19 15 02 21


    SUMMARY.xls (TAB1) - this tab will sum all the cells from the above examples and keep the formatting the same:

    Column A Column B Column C Column D
    56 66 91 34
    48 41 26 55

    Any suggestions please?

    Mav

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Summing multiple spreadsheets into 1

    what about a formula in the summary worksheet?

    =sum('[test1.xls]tab1'!a1, '[test2.xls]tab1'!a1, '[test3.xls]tab1'!a1)

    copy the formula into the required range
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2008
    Location
    U.K.
    Posts
    65

    Re: Summing multiple spreadsheets into 1

    I was thinking of using a formula but I would have to do it in over 10,000 cells so thought it would be easier to do it in vba. There are also about 15 spreadsheets so would take me an age to do

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Summing multiple spreadsheets into 1

    you only need to put in 1 cell then drag
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5
    Addicted Member
    Join Date
    Mar 2005
    Posts
    222

    Re: Summing multiple spreadsheets into 1

    Hi Maver1ck666

    How about something like this to fill the range you want with the formula westconn1 provided.
    Code:
    Sub Fill_Column_Range_with_Formula()
    
    Dim rng As Range
    Dim wks As Object
    
    Set wks = Worksheets("tab1")
    
    With wks
        Set rng = .Range("A1:A3")
    End With
           
         rng.ClearContents
         
         rng.NumberFormat = "General"
          
         rng.Formula = "=sum('[test1.xls]tab1'!a1, '[test2.xls]tab1'!a1, '[test3.xls]tab1'!a1)"
        
    End Sub

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2008
    Location
    U.K.
    Posts
    65

    Re: Summing multiple spreadsheets into 1

    I opted in the end to hard link the spreadsheets in the main stats sheet. Cheers for all your help though

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width