简体   繁体   English

如何将数据从启用宏的Excel工作簿复制到另一个Excel文件

[英]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. 我正在尝试将数据从启用宏的Excel工作表复制到简单的Excel文件中。 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. 我在工作表中编写VBA代码,其中还有一个宏用于某些其他功能。

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 复制后放置Destination:=

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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