Consolidating Multiple Workbooks into one Data Range

rolo1989

New Member
Joined
Oct 31, 2011
Messages
3
Hi All,

I am trying to consolidate a specific data range from Mutliple workbooks into one Master sheet in the file where the code is written.

I recently read the following thread which the user aimed to do the same thing...consolidate a specific data range from multiple workbooks. (http://www.mrexcel.com/forum/showthread.php?t=507942&highlight=multiple+sources&page=2)

So I used the code that finally worked for him and adapted it BUT it is not selecting and 'summing' the correct cells. The range of cells that I want to sum data from is C8:T10 and I have it so that I can select the files that I would like to sum but it is not doing it!

I am sure it is probably something simple that I am missing, please help!

The code I have so far is;

Code:
Sub consolidateall4()
    Dim DestCell As Range
    Dim WB As Workbook
    Dim FileNames As Variant
    Dim N As Long
    Dim Temp As String
    Set DestCell = ThisWorkbook.Worksheets("Master").Range("C8:T10")
    FileNames = Application.GetOpenFilename( _
        filefilter:="Excel Files (*.xls*),*.xls*", _
        Title:="Choose File", MultiSelect:=True)
    If IsArray(FileNames) = False Then
        If FileNames = False Then
'           User cancelled open dialog. get out.
            Exit Sub
        End If
    End If
'   Loop through all the selected files.
    Application.ScreenUpdating = False
    For N = LBound(FileNames) To UBound(FileNames)
'       Open the workbook
        Set WB = Workbooks.Open(Filename:=FileNames(N), ReadOnly:=True)
        Temp = Temp & ("'" & WB.Path & "\[" & WB.Name & "]Q1'!R12C3:R32C6") & ","
'       Close the workbook
        WB.Close savechanges:=False
    Next N
    DestCell.Consolidate _
            Sources:=Split(Left(Temp, Len(Temp) - 1), ","), _
            Function:=xlSum
            
    Application.ScreenUpdating = True
    ActiveWorkbook.Sheets("Master").Select
End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,224,891
Messages
6,181,614
Members
453,057
Latest member
LE102024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top