+ Reply to Thread
Results 1 to 7 of 7

Consolidate Divisional Sheets to Corporate Summary

Hybrid View

  1. #1
    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

    Consolidate Divisional Sheets to Corporate Summary

    I'm attempting to consolidate Divisional Sheets into a Corporate Summary. I've searched the net for a week on this subject and have not found a working solution. The following code is a compilation of code I've found
    Option Explicit
    Public Sub ImportData()
        Dim shArray() As Variant
        Dim sh() As Variant
        Dim x() As Variant
        Dim n As Integer
        Dim i As Integer
    
        Application.ScreenUpdating = False
        n = Sheets.Count
        ReDim sh(n), shArray(n)
        For i = 1 To Sheets.Count
            sh(i) = Sheets(i).Name
            Debug.Print sh(i)
        Next
    
        For i = 1 To n - 1
            sh(i) = Worksheets(i + 1).Name
            shArray(i) = Array("'" & sh(i) & "'!R1C1:R70C13")
        Next i
        x = shArray
    
        Worksheets("Consolidated").Range("A1").Consolidate _
                Sources:=x, _
                Function:=xlSum
        Application.ScreenUpdating = True
    End Sub
    I get a "Type Mismatch" error at this line of code
    Worksheets("Consolidated").Range("A1").Consolidate _
                Sources:=x, _
                Function:=xlSum
    I can do this other ways but this is part of a much larger monthly consolidation process. I'd appreciate it if you could look at the attached workbook and give me some direction.
    J
    Attached Files Attached Files
    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.

  2. #2
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Re: Consolidate Divisional Sheets to Corporate Summary

    It appears that the variable "shArray(i)" is null. Thus your type mismatch error.

    FYI, adding "MsgBox shArray(i)" after "x = shArray" displays an empty message box.
    Regards

    Rick
    Win10, Office 365

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Consolidate Divisional Sheets to Corporate Summary

    The Summary sheet example shows how t do this without VBA

    http://excel-it.com/workbook_downloads.htm
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    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: Consolidate Divisional Sheets to Corporate Summary

    This is an interesting approach http://excel-it.com/workbook_downloads.htm and I'm certain I'll use it for some applications. What I'm interested in is creating an array of sheets to be "consolidated" with the "Consolidate" function in VBA. Any idea how to make this work?
    J

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Consolidate Divisional Sheets to Corporate Summary

    When I try using Consolidate I get an error message saying that Excel cannot open the sheets. I haven't found any working examples of Consolidate and I cannot see how it is different to the method on my website, which I would think is more flexible in that you can move sheets out of the consolidation for comparisons/what ifs.

  6. #6
    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: Consolidate Divisional Sheets to Corporate Summary

    I've spent days on this topic and I too have been unable to find any "working" solutions using the "consolidate" function in VBA. I'll spend some time with your approach, importing files from different workbooks and see what i can put together.
    Thanks for your input. J

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Consolidate Divisional Sheets to Corporate Summary

    Post back if you want further help

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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