Guest User

Untitled

a guest
Jun 23rd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. Sub LoopThroughDirectory()
  2. Dim MyFile As String
  3. Dim Filepath As String
  4. Dim count as Integer
  5. Filepath = "D:DATA"
  6. MyFile = Dir(Filepath)
  7. count = 1
  8. Application.ScreenUpdating = False
  9.  
  10. While MyFile <> ""
  11. If MyFile = "master.xlsm" Then Exit Sub
  12. Workbooks.Open (Filepath & MyFile)
  13. Workbooks(MyFile).sheets("Sheet1").Range("F1:F100").Copy thisworkbook.sheets("Sheet1").Cells(3, count)
  14. Workbooks(MyFile).Close
  15. count = count + 1
  16. MyFile = Dir
  17. Loop
  18.  
  19. Application.ScreenUpdating = True
  20. End Sub
Add Comment
Please, Sign In to add comment