Question:

I have an  Excel workbook with 64 separate sheets called `Table001 (Page 1)`, `Table001 (Page 2)`, etc. I wish to copy all to `Sheet1`.  What's the best way to merge all of the sheets into one?


Answer:

The most efficient way to achieve this is by using a VBA (Visual Basic for Applications) macro. This allows you to loop through all the sheets and copy their contents into Sheet1. Here’s how you can do it:

1. Open the VBA Editor:

oPress Alt + F11 in Excel.

2. Insert a New Module:

oIn the VBA editor, click Insert > Module.

3. Paste the Following Code:

Sub MergeSheetsToSheet1()

    Dim ws As Worksheet

    Dim targetSheet As Worksheet

    Dim lastRow As Long

    Dim pasteRow As Long

    

    ' Set reference to Sheet1

    Set targetSheet = ThisWorkbook.Sheets("Sheet1")

    pasteRow = 1 ' Start pasting from row 1

    

    ' Loop through all sheets

    For Each ws In ThisWorkbook.Sheets

        If ws.Name <> "Sheet1" Then

            ' Find the last used row in the source sheet

            lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row

            

            ' Copy data

            ws.Range("A1", ws.Cells(lastRow, ws.Columns.Count).End(xlToLeft)).Copy

            

            ' Paste in Sheet1

            targetSheet.Cells(pasteRow, 1).PasteSpecial Paste:=xlPasteValues

            

            ' Update pasteRow for the next data

            pasteRow = targetSheet.Cells(targetSheet.Rows.Count, "A").End(xlUp).Row + 1

        End If

    Next ws

    

    ' Clear clipboard

    Application.CutCopyMode = False

    

    MsgBox "All sheets have been copied to Sheet1."

End Sub

4. Run the Macro:

oClose the VBA editor by pressing Alt + Q.

oBack in Excel, press Alt + F8, select MergeSheetsToSheet1, and click Run.

This macro assumes that each sheet has data starting from cell A1 and copies all the data to Sheet1. Modify the range selection within the code if your data starts elsewhere or includes specific columns.



Topic last reviewed: 15/09/25