本文介绍了从第一个工作簿复制到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个宏,该宏将数据从一个工作簿传输到另一个工作簿.我遇到错误,请帮忙.我已经在b.xls上的工作簿上执行了命令按钮,它将运行此按钮.



i am creating a macro that transfer data from one workbook to another. i am getting a error please help. i have taken command button on workbook on b.xls which will run this.



Private Sub CommandButton1_Click()

Dim wkb1 As Workbook
Dim wknm As String
wknm = "d:\a.xlsx";
Set wkb1 = Workbooks.Open(wknm)
wkb1.Sheets("Sheet1").Range("A1:A8").Copy

ThisWorkbook.Sheets("Sheet1").Range("A1").Select
Selection.Paste

End Sub


请帮助我找出我做错了什么
谢谢
aks619


Please help me find out what i am doing wrong
Thanks
aks619

推荐答案

Public Sub test()
Dim wb As Workbook
Set wb = Workbooks.Add
Workbooks(1).Activate
ActiveSheet.Range("A1").Value = 1
ActiveSheet.Range("A8").Value = 8
ActiveSheet.Range("A1:A8").Select
Selection.Copy
Workbooks(2).Activate
ActiveSheet.Range("A1").Select
ActiveSheet.Paste
End Sub


这篇关于从第一个工作簿复制到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 17:37