Excel copy from one workbook to another with VBA. Also Create new Worksheet.
Often we want to copy data from One excel file to another Excel file. To know, how to Transfer data from one Excel worksheet to another? Let’s See.
Following VBA Code can copy data from One worksheet of a workbook to another workbooks worksheet.
Sub open_copy()
' Open Excel file path
Workbooks.Open "D:\f\ok.xlsx"
' Copy Data to another file
Workbooks("ok.xlsx").Worksheets("Sheet1").Range("A1").Value = Workbooks("Book1.xlsx").Worksheets("Sheet1").Range("A1").Value
' Add Worksheet
Workbooks("ok.xlsx").Worksheets.Add.Name = "OK"
'Close Excel Workbook
Workbooks("ok.xlsx").Close savechanges:=True
End Sub
Here, Excel files are – Book1.xlsx and ok.xlsx
Code written in Book1.xlsx
We want to copy data from Book1.xlsx to ok.xlsx along with New sheet “ok” is added in ok.xlsx
So simple to backup or copy data to another worksheet.