Data consolidation from 1) Multiple .xls within a folder 2) Internal worksheets

redinto

New Member
Joined
Jan 17, 2012
Messages
17
Hello,

I have the following code:

HTML:
Sub Merge2MultiSheets()
Dim wbDst As Workbook
Dim wbSrc As Workbook
Dim wsSrc As Worksheet
Dim MyPath As String
Dim strFilename As String
Dim LastRow As Long
Dim wsht As Worksheet
Dim i As Integer
 
    Application.DisplayAlerts = False
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    MyPath = "\\....." ' change to suit
    Set wbDst = Workbooks.Add(xlWBATWorksheet)
    strFilename = Dir(MyPath & "\*.xls", vbNormal)
 
    If Len(strFilename) = 0 Then Exit Sub
 
    Do Until strFilename = ""
 
            Set wbSrc = Workbooks.Open(Filename:=MyPath & "\" & strFilename)
 
            Set wsSrc = wbSrc.Worksheets(1)
 
            wsSrc.Copy After:=wbDst.Worksheets(wbDst.Worksheets.Count)
            wbSrc.Close False
 
        strFilename = Dir()
 
    Loop
    wbDst.Worksheets(1).Delete
 
    Sheets.Add
    ActiveSheet.Name = "Summary"
 
    For Each wbDst In ThisWorkbook.Worksheets
        If wbDst.Name <> "Summary" Then
            wbDst.UsedRange.Offset(4, 0).Copy Destination:=Sheets("Summary").Range("A94526").End(xlUp).Offset(1, 0)
        End If
    Next wbDst
 
    Application.DisplayAlerts = True
    Application.EnableEvents = True
    Application.ScreenUpdating = True
 
 
End Sub

where I want to modify it and:

1) Rename the new 'master' file as "Consolidation" and save it into the same location as the Path.

2) Perform the consolidation from all the new created tabs into one with name "Summary"

(The code opens the targeted spreadsheets, creates a new file with name: Sheet1, Sheet2 or in this format and then it creates the Tab Summary) It doesnt do the consolidation of the internal tabs and cannot find a way for the renaming and save into the same folder as my path.

Thank you in advance for any help.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,215,390
Messages
6,124,670
Members
449,178
Latest member
Emilou

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