vba从一个工作簿复制到另一个工作簿

时间:2014-10-16 09:24:53

标签: vba excel-vba copy excel

我试图使用以下vba代码将单元格值从一个工作簿复制到另一个工作簿,但是当我运行代码时,我得到一个超出范围的下标错误消息,我不知道为什么?

请有人告诉我我做错了什么,谢谢

Dim ws10 As Worksheet, ws12 As Worksheet
Dim DestRow As Long
Dim objExcel
Dim objWkb
Set objExcel = CreateObject("Excel.Application")
Set objWkb = objExcel.Workbooks.Open("\\UKSH000-FILE06\Purchasing\New_Supplier_Set_Ups_&_Audits\Supplier Tracking & Management.xls")
Set objWkb2 = Workbooks("\\UKSH000-FILE06\Purchasing\New_Supplier_Set_Ups_&_Audits\Supplier SetUps & Amendments.xls")
Set ws12 = objWkb.Sheets("SupplierTracking")
Set ws10 = objWkb2.Sheets("Statistics")
DestRow = ws12.Cells(Rows.Count, "B").End(xlUp).Row + 1
ws10.Range("A" & ActiveCell.Row).Copy
ws12.Range("B" & DestRow).Paste

0 个答案:

没有答案