Merging spreadsheets using a macro

DaRTH KiRo

New Member
Joined
Jan 24, 2018
Messages
39
Office Version
  1. 2016
Platform
  1. Windows
I have 3 excel sheets, listed below, I need to merge them into a new spreadsheet 'Master_Signups & Testing'. The 3 different spreadsheets below contain the same columns but the information in the rows are different and new rows are always being added. Is there a way to add a macro to 'Master_Signups & Testing' that will automatically pull the information from the other 3 sheets every time it's opened or a command is entered?

2018_Heather_Signups & Testing.xlsm
2018_Isabelle_Signups & Testing.xlsm
2018_Natalie_Signups & Testing.xlsm
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Code:
Sub MacImportSheets()
  'Copy all sheets to a master
    Sheets("[COLOR=#333333][FONT=Verdana]Master_Signups & Testing[/FONT][/COLOR]").Activate
    Dim Sht As Worksheet
        For Each Sht In ActiveWorkbook.Worksheets
            If Sht.Name <> "[COLOR=#333333][FONT=Verdana]Master_Signups & Testing[/FONT][/COLOR]" Then
                Sht.Select
                Range("A1").CurrentRegion.Copy
                Sheets("Master").Select
                Sheets("Master").Activate
                Range("A65536").End(xlUp).Offset(1, 0).Select
                ActiveSheet.Paste
                Else
            End If
        Next Sht
    End Sub
 
Last edited:
Upvote 0
Do I place this in the master spreadsheet I am creating or all the spreadsheets that are being merged?
 
Upvote 0
When in VBA, you have "this workbook" below the name of all the sheets, 2x click it and paste this macro
Code:
Private Sub Workbook_Open()
  'Copy all sheets to a master
    Sheets("Master_Signups & Testing").Activate
[LEFT][COLOR=#333333][FONT=monospace]Range("A1").CurrentRegion.clearcontent[/FONT][/COLOR][/LEFT]
    Dim Sht As Worksheet
        For Each Sht In ActiveWorkbook.Worksheets
            If Sht.Name = "Master_Signups & Testing" Then
                Sht.Select
                Range("A2").CurrentRegion.Copy
                Sheets("Master_Signups & Testing").Select
                Sheets("Master_Signups & Testing").Activate
                Range("A65536").End(xlUp).Offset(1, 0).Select
                ActiveSheet.Paste
                Else
            End If
        Next Sht
    End Sub
End Sub

The macro will run whenever you open the workbook. But I think you made a mistake in your explanation. Sheets are part of a workbook, so this macro copy all the sheets of the workbook that are not the master sheet below one another in the master sheet. I think that what you mean was 3 workbooks (I just realized your sheet names were .xlsm). The easiest way to do it if this is the case would be to record the opening and move the sheet from each workbook to this one, place it in frnt of the macro and delete the sheets when it is done.
 
Last edited:
Upvote 0
Solution

Forum statistics

Threads
1,223,893
Messages
6,175,242
Members
452,623
Latest member
russelllowellpercy

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