Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. Sub MergeDataFiles()
  2.  
  3. Dim sPath As String
  4. Dim MyFile As String
  5. Dim wBk As Workbook
  6. sPath = InputBox("Paste File Path Here")
  7. MyFile = Dir(sPath & "*.xl*")
  8.  
  9. Application.EnableEvents = False
  10. Application.ScreenUpdating = False
  11.  
  12. Do While Len(MyFile) > 0
  13. Set wBk = Workbooks.Open(sPath & MyFile)
  14. wBk.Sheets(1).Copy After:=ThisWorkbook.Sheets(1)
  15. wBk.Close True
  16. MyFile = Dir()
  17. Loop
  18.  
  19. ActiveWorkbook.Save
  20. Application.EnableEvents = True
  21. Application.ScreenUpdating = True
  22.  
  23. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement