小编Fre*_*ind的帖子

VBA宏将数据从一个excel文件复制到另一个excel文件

我有2本Excel工作簿.两者都在不同的文件夹中.我使用a将数据从一个复制到另一个macro.

我观察到一个超出范围错误的下标......

对此有何见解?

这是我的代码

Sub copydata()
Dim wkbSource As Workbook
Dim wkbDest As Workbook
Dim shttocopy As Worksheet
Dim wbname As String

' check if the file is open 
ret = Isworkbookopen("C:\file1.xlsx") 
If ret = False Then
' open file
Set wkbSource = Workbooks.Open("C:\file1.xlsx")
Else
'Just make it active
 Workbooks("C:\file1.xlsx").Activate
 End If

' check if the file is open 

ret = Isworkbookopen("C:\File2.xlsx")
If ret = False Then
' open file
Set wkbDest = Workbooks.Open("C:\file2.xlsx")
Else
'Just …
Run Code Online (Sandbox Code Playgroud)

excel vba excel-vba

1
推荐指数
1
解决办法
9万
查看次数

标签 统计

excel ×1

excel-vba ×1

vba ×1