I am trying to copy a specific worksheet (called "Edit") from a folder full of workbooks (190). I have the following code to do this:
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
When I run the Macro, I get the dialog box asking to name the sheet to copy from all matching workbooks. I enter Edit, and get the message
Run-time error '76': Path not found
Can anyone tell me what needs to be changed in the code to make this work.?