简体   繁体   中英

How to copy data from macro enabled Excel workbook to another Excel file

I am trying to copy data from macro enabled Excel sheet to simple Excel file. But following code is throwing error like object not found.

I am writing VBA code in sheet having one more macro for some other functionality.

Private Sub CommandButton2_Click() 
    Workbooks("JHG raw data.xlsm").Worksheets("Summary").Range("A1:D300").Copy_
    Workbooks("JHG summary.xlsx").Worksheets("Data").Range ("A1")
End Sub

Put Destination:= after Copy

Workbooks("JHG raw data.xlsm").Worksheets("Summary").Range("A1:D300").Copy _
        Destination:=Workbooks("JHG summary.xlsx").Worksheets("Data").Range ("A1")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM