HELP: Compile Sheets Into ONE Tab

sungersoo

New Member
Joined
Nov 9, 2017
Messages
34
VBA: Compile 5 out of 10 sheets into 1

Hello!

I have made a macro to basically take 5 data sources and order them into new order by headers. Now I have 5 sheets into a workbook of 10 that is set in the same order with same headers.

Is there a macro out here that would compile the 5 sheets (with same headers) into one sheet? I have tried several online but due to the lines not being static, it would not work.

Thank you very much in advance!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Re: VBA: Compile 5 out of 10 sheets into 1

What are the names of the 5 sheets and do you want them combined into a new sheet or simply to copy 4 of the sheets to the first sheet?
 
Upvote 0
Re: VBA: Compile 5 out of 10 sheets into 1

Combined would be the sheet I would want the following sheets be compiled to:
Import
HG Import
HG Import2
Moose Import
CSFE
 
Upvote 0
Re: VBA: Compile 5 out of 10 sheets into 1

I am assuming that the "Combined" sheet is blank and that the 5 sheets have the same headers in the same order.
Code:
Sub CombineSheets()
    Application.ScreenUpdating = False
    Dim ws As Worksheet
    Sheets("Import").UsedRange.Cells.Copy Sheets("Combined").Cells(1, 1)
    For Each ws In Sheets(Array("HG Import", "HG Import2", "Moose Import", "CSFE"))
        ws.UsedRange.Offset(1, 0).Copy Sheets("Import").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
    Next ws
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Re: VBA: Compile 5 out of 10 sheets into 1

That macro got me where it would compile all of them to "Import" instead of "Combined" and also some pieces of data weren't copied over...
@mumps Is there something I am missing?
 
Upvote 0
Re: VBA: Compile 5 out of 10 sheets into 1

Try:
Code:
Sub CombineSheets()
    Application.ScreenUpdating = False
    Dim ws As Worksheet
    Sheets("Import").UsedRange.Cells.Copy Sheets("Combined").Cells(1, 1)
    For Each ws In Sheets(Array("HG Import", "HG Import2", "Moose Import", "CSFE"))
        ws.UsedRange.Offset(1, 0).Copy Sheets("Combined").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
    Next ws
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Re: VBA: Compile 5 out of 10 sheets into 1

Where is the empty row?
 
Upvote 0
Re: VBA: Compile 5 out of 10 sheets into 1

i.e. when hg import gets compiled into COMBINED and then hg import2. There would be a empty row in between hg import and hg import2.
 
Upvote 0
Re: VBA: Compile 5 out of 10 sheets into 1

You have headers in row 1. Is this correct? Does your data start in row 2 or row 3?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
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