merge multiple files and all sheets

nldstorm

New Member
Joined
Sep 20, 2009
Messages
15
Need your help!

Do you know what the macro would be if I want to merge different sheets (having the same amount of rows but columns may be different) for all open files? With other words, I will have 5 files open, some with 5 sheets and some with one sheet and would like to have all columns out of these 5 files returned into one master sheet.

Thanks!
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,406
For each opened workbook, except the active workbook, the data from each sheet will be copied to the active sheet...

Code:
Option Explicit

Sub test()

    Dim wkbDest As Workbook, wkb As Workbook
    Dim wksDest As Worksheet, wks As Worksheet
    
    Application.ScreenUpdating = False

    Set wkbDest = Application.ThisWorkbook
    Set wksDest = wkbDest.ActiveSheet
    
    For Each wkb In Workbooks
        If wkb.Name <> wkbDest.Name Then
            For Each wks In wkb.Worksheets
                wks.UsedRange.Copy Destination:=wksDest.Cells(wksDest.Rows.Count, 1).End(xlUp)(2)
            Next wks
        End If
    Next wkb
    
    Application.ScreenUpdating = True
    
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,123,519
Messages
5,602,141
Members
414,505
Latest member
quoctrungvu99

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
Top