我正在尝试从装满工作簿的文件夹中复制特定的工作表(称为“编辑”)(190)。我有以下代码可以做到这一点:
Option Explicit
Sub CombineSheets()
Dim sPath As String
Dim sFname As String
Dim wBk As Workbook
Dim wSht As Variant
Application.EnableEvents = False
Application.ScreenUpdating = False
sPath = InputBox("M:\Employee Information\Peter Young\Msc Project\1 - 181028 - Office First Floor\MacroCopy")
ChDir sPath
sFname = InputBox("*")
sFname = Dir(sPath & "\" & sFname & ".xl*", vbNormal)
wSht = InputBox("Edit")
Do Until sFname = ""
Set wBk = Workbooks.Open(sFname)
Windows(sFname).Activate
Sheets(wSht).Copy Before:=ThisWorkbook.Sheets(1)
wBk.Close False
sFname = Dir()
Loop
ActiveWorkbook.Save
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
运行宏时,出现对话框,要求命名工作表以从所有匹配的工作簿中复制。我输入“编辑”,并收到消息“运行时错误'76':找不到路径”,谁能告诉我要更改此代码需要进行什么操作??