Macro to combine multiple workbooks

spectraflame

Well-known Member
Joined
Dec 18, 2002
Messages
830
Office Version
  1. 365
Platform
  1. Windows
I would like to combine 12 separate workbooks into a single Workbook but have the data from each in a separate Worksheet. Any suggestions on how to get started?
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
If you have excel 2010, I believe you have to download Power Query from MS. If that is an option for you, there are some good videos that will help, if not an option, then VBA would be the way to go.

If you need to get VBA help, you should add more details, like are all of the files exactly the same for headings / fields - is there only one worksheet in each of the workbooks or multiples, etc.
 
Upvote 0
If you have excel 2010, I believe you have to download Power Query from MS. If that is an option for you, there are some good videos that will help, if not an option, then VBA would be the way to go.

If you need to get VBA help, you should add more details, like are all of the files exactly the same for headings / fields - is there only one worksheet in each of the workbooks or multiples, etc.

Since this sheet would be used by multiple people, I would have to ensure the add-in was installed on each workstation so using VBA would be easier I believe. Each file will have the same number of columns and headings. There is only a single worksheet in each of the workbooks and they will always be in .csv format.
 
Upvote 0
When you say:

"... and they will always be in .csv format."

what do you mean. Have the csv files been imported into Excel, into separate columns / fields?
 
Upvote 0
When you say:

"... and they will always be in .csv format."

what do you mean. Have the csv files been imported into Excel, into separate columns / fields?

The original files will be created by a different software program, one for each of the previous 12 months. They will have unique file names with the same number of columns but different rows. The end goal is to allow the end user to import the data and create a summary page for each of the 12 months. My original thought was to just have 12 blank tabs, one for each month, and have the user just City and paste the data into the appropriate sheet which may be the easiest way to do it.
 
Upvote 0
Hello, take a look at this and see if this is what you want to do (video from Mrexcel):

NOTE: Always test the code on a copy of your data.

https://www.youtube.com/watch?v=n9WcP18wXFA

Or see here:

https://www.mrexcel.com/forum/excel...le-worksheets-into-one-new-worksheet-vba.html

There are a lot of threads here covering combining worksheets using VBA.

Some code I found:

Code:
Sub Combine()
    Dim J As Integer
    Dim s As Worksheet

    On Error Resume Next
    Sheets(1).Select
    Worksheets.Add ' add a sheet in first place
    Sheets(1).Name = "Combined"

    ' copy headings
    Sheets(2).Activate
    Range("A1").EntireRow.Select
    Selection.Copy Destination:=Sheets(1).Range("A1")

    For Each s In ActiveWorkbook.Sheets
        If s.Name <> "Combined" Then
            Application.GoTo Sheets(s.Name).[a1]
            Selection.CurrentRegion.Select
            ' Don't copy the headings
            Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select
            Selection.Copy Destination:=Sheets("Combined"). _
              Cells(Rows.Count, 1).End(xlUp)(2)
        End If
    Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

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