By: Alok Paul

In reply to Narasimhan S.

Hi NARASIMHAN S,
You can copy data as values from the selected worksheets to another workbook using the VBA code. Here, Workbook1 is our source and Workbook2 is our destination Excel file. We want to copy data from Sheet1 of Workbook1. Use the below code on Workbook1.

VBA Macro to Copy Data of a Sheet into Another Workbook:

Sub Copy_Sheet_Another_Workbook_1()
Sheets(“Sheet1”).Copy Before:=Workbooks(“Workbook2.xlsm”).Sheets(1)
End Sub

Code Breakdown

Sheets(“Sheet1”).Copy Before:=Workbooks(“Workbook2.xlsm”).Sheets(1)
This will copy Sheet1 of the active workbook (Workbook1) into Workbook2 before 1st sheet. If you want to copy after 1st sheet of Workbook2, use After instead of Before in the VBA code.

One thing needs to keep in mind, that is both workbooks must be kept open in this case. The destination workbook name is mentioned in the VBA code. But if the source workbook is closed, you can use the VBA code below.

VBA Macro to Copy Data of a Closed Sheet into Another Workbook:

Sub Copy_Sheet_Another_Workbook_2()
Application.ScreenUpdating = False
Set sourcedBook = Workbooks.Open(“C:\Users\alokp\OneDrive\Desktop\Workbook1.xlsm”)
sourcedBook.Sheets(“Sheet1”).Copy Before:=ThisWorkbook.Sheets(1)
sourcedBook.Close SaveChanges:=False
Application.ScreenUpdating = True
End Sub

We applied this VBA code to Workbook2 and Workbook1 is closed. We inserted the location of Workbook1 and mentioned the sheet name in the VBA code. In both cases, we need to mention the source sheet name in the VBA code.