How to Copy Worksheet to Another Workbook Using VBA

For illustration, we have a sample workbook named “Source” with three worksheets “List-1″, “List-2”, and “List-3”.

dataset

We will copy these worksheets to a workbook named “Destination”.

destination


Method 1 – Copy Single Worksheet to Another Workbook

1.1. Before the First Sheet of Another Workbook

To copy the worksheet before the first sheet of another workbook,

➤ Press ALT + F11 to open the VBA window.

In the VBA window,

➤ Click on the Insert tab and select Module.

module

It will open the Module(Code) window.

➤ Insert the following code in the Module(Code) window,

Sub Copy_to_Another_single()
Sheets("List1").CopyBefore:=Workbooks("Destination.xlsx").Sheets(1)
End Sub

The code will copy the worksheet “List-1” before the first sheet of the workbook “Destination.xlsx”.

code

 

➤ Click on the Run icon or press F5.

code

If you open the “Destination” workbook you’ll see the “List-1” worksheet has been inserted before the first sheet of the workbook.

copy worksheet to another workbook vba


1.2. Before a Specific Sheet of Another Workbook

You can also copy the worksheet before any specific sheet of another workbook.

➤ Open VBA and run the following code. In the code, enter the name of the worksheet (e.g. Sheet2) before which you want to copy your current sheet.

Sub Copy_to_Another_single()
Sheets("List-1").Copy Before:=Workbooks("Destination.xlsx").Sheets("Sheet 2")
End Sub

code

The sheet will be copied before “Sheet2” of the “Destination” Workbook.

copy worksheet to another workbook vba


1.3. At the End of Another Workbook

To copy the worksheet at the end of the “Destination” workbook, use the following code instead of the previous code.

Sub Copy_to_Another_single()
Sheets("List-1").Copy After:=Workbooks("Destination.xlsx").Sheets(Sheets.count)
End Sub

code

The sheet will be copied at the end of the “Destination” Workbook.

copy worksheet to another workbook vba

Read More: How to Copy Sheet to End in Excel Using VBA


Method 2 – Copy Multiple Sheets to Another Workbook

To copy multiple sheets,

➤ Insert the following code in the Module(Code) window,

Sub Copy_to_Another_Multiple()
Sheets(Array("List-1", "List-2", "List-3")).Copy Before:=Workbooks("Destination.xlsx").Sheets(1)
End Sub

The code will copy the worksheets “List-1”, “List-2” and “List 3” to the workbook “Destination.xlsx”.

copy worksheet to another workbook vba

 

➤ Press F5 to run the code.

The worksheets will be copied into the workbook “Destination.xlsx”.

copy worksheet to another workbook vba


Method 3 – Copy Worksheet to a Closed Workbook

To copy the sheet named “List 1″ to the “Destination” workbook which is not opened,

➤ Insert the following code in the Module(Code) window,

Sub Copy_to_closed_Workbook()

Dim closedbook As Workbook
Application.ScreenUpdating = False
Set closedbook = _
Workbooks.Open _
("C:\Users\User\Desktop\Destination.xlsx")
Workbooks("Source.xlsx").Sheets("List-1").Copy Before:=closedbook.Sheets(1)
closedbook.Close SaveChanges:=True
Application.ScreenUpdating = True

End Sub

C:\Users\User\Desktop\Destination.xlsx is the location of the Destination workbook. You have to put the location of the workbook in which you want to copy the sheet. The code will first open the workbook, copy the sheet in the workbook, and close the workbook.

copy worksheet to another workbook vba

 

➤ Press F5 to run the code.

The sheet has been copied to workbook Destination.

copy worksheet to another workbook vba


Method 4 – Copy Excel Sheet to a New Workbook

➤ Insert the following code in the Module(Code) window,

Sub Copy_to_New_Single()
Sheets("List-1").Copy
End Sub

The code will copy the worksheet “List-1” to a new workbook.

copy worksheet to another workbook vba

 

➤ Press F5 to run the code.

A new workbook will be opened with the copied sheet.

copy worksheet to another workbook vba


Method 5 – Copy Multiple Worksheets to a New Workbook

You can also copy multiple sheets to a new workbook.

➤ Insert the following code in the Module(Code) window,

Sub Copy_to_Another_Multiple()
Sheets(Array("List-1", "List-2", "List-3")).Copy
End Sub

The code will copy the worksheets “List-1”, “List-2” and “List-3” to a new workbook.

copy worksheet to another workbook vba

 

➤ Press F5 to run the code.

A new workbook will be opened with all of the sheets mentioned in the code.

copy worksheet to another workbook vba


Download Practice Workbooks

Source workbook

Destination workbook


Related Articles

Get FREE Advanced Excel Exercises with Solutions!
Prantick Bala
Prantick Bala

PRANTICK BALA is a marine engineer who loves exploring Excel and VBA programming. Programming, to him, is a time-saving tool for efficiently managing data, files, and internet tasks. He is proficient in Rhino3D, Maxsurf, C++, MS Office, AutoCAD, Excel, and VBA and goes beyond the basics. Armed with a B.Sc in Naval Architecture & Marine Engineering from BUET, he has transitioned into the role of a content developer. Beyond his work, find him immersed in books, exploring new... Read Full Bio

4 Comments
  1. How to Copy closed-Worksheet to Another closed-Workbook Using VBA ?

    I modified your code as below, but I got a error at “Workbooks(“File01.xlsx”).Sheets(“Sheet1″).Copy Before:=closedbook.Sheets(1) ”

    Sub VBAcopytest()

    Dim closedbook As Workbook

    Application.ScreenUpdating = False

    Set closedbook = _
    Workbooks.Open _
    (“C:\Users\willy\OneDrive\dataNAVtest2\File02.xlsm”)

    Workbooks(“File01.xlsx”).Sheets(“Sheet1”).Copy Before:=closedbook.Sheets(1)
    closedbook.Close SaveChanges:=True
    Application.ScreenUpdating = True

    End Sub

    • hi Willy,

      Make sure the file names are correctly spelled in the line. Check if both the source file and target file name are correct as well as if the directory of the workbook file is correct too.

      If the problem still persists, please provide us with a bit of more information, like what is the error message or perhaps a screenshot.

  2. I am looking for a way to create a copy of a worksheet that will automatically update in a new workbook as it receives form responses but only if the response contains a certain category. Is this possible?

    • Hi BZ, thanks for your response. You can reference the cells from one sheet to another workbook. That way, you can automatically update data in the new workbook when you make a change in the existing worksheet. And to update with condition, you need to use conditional function like the IF, AND, OR, EXACT etc. functions.

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo