VBA运行时424对象必需

时间:2017-01-06 11:35:19

标签: excel vba excel-vba

我正在尝试将多个工作表复制到新工作簿。我需要将不同工作簿中的3张表复制到一张表中的新创建工作簿中。

这是我的代码:

Private Sub CommandButton1_Click()

Path = "C:\Users\vnohavcova\Desktop\New folder\DB earnie report\"
fileName = Dir(Path & "*.xls")

Do While fileName <> ""
    Workbooks.Open fileName:=Path & fileName, ReadOnly:=True
    For Each sheet In ActiveWorkbook.Sheets
        sheet.Copy After:=DestWkb.Sheets(1)
    Next sheet
    Workbooks(fileName).Close
    fileName = Dir()
Loop

0 个答案:

没有答案