如何用VBA将一个工作薄里的多个工作表导入到另一个excel文档工作表里?
1个回答
展开全部
下面的代码是导入指定工作薄的所有工作表
Sub 导入()
drfile = InputBox("请输入要导入的excel文件名(不包含扩展名):", "输入")
drfile = drfile & ".xls"
Workbooks.Open ThisWorkbook.Path & "\" & drfile
drcount = Workbooks(drfile).Sheets.Count
For i = 1 To drcount
With Workbooks(drfile)
.Sheets(i).Copy after:=ThisWorkbook.Sheets(Sheets.Count)
End With
Next
Workbooks(drfile).Close False
End Sub
Sub 导入()
drfile = InputBox("请输入要导入的excel文件名(不包含扩展名):", "输入")
drfile = drfile & ".xls"
Workbooks.Open ThisWorkbook.Path & "\" & drfile
drcount = Workbooks(drfile).Sheets.Count
For i = 1 To drcount
With Workbooks(drfile)
.Sheets(i).Copy after:=ThisWorkbook.Sheets(Sheets.Count)
End With
Next
Workbooks(drfile).Close False
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询