Advertisement
Guest User

Untitled

a guest
May 30th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. Sub Tank()
  2. Dim wb As Workbook
  3. Dim myPath As String
  4. Dim myfile As String
  5. Dim myExtension As String
  6. Dim SheetName As String
  7. 'Optimize Macro Speed
  8. Application.ScreenUpdating = False
  9. Application.EnableEvents = False
  10. Application.Calculation = xlCalculationManual
  11.  
  12. SheetName = "Tankard*"
  13. myPath = "\ph00winfdfs01psharesJoeyCdocumentsRoamingWindowsDesktopTank"
  14. If myPath = "" Then GoTo ResetSettings
  15.  
  16. 'Target File Extension (must include wildcard "*")
  17. myExtension = "Tankard*.csv"
  18.  
  19. 'Target Path with Ending Extention
  20. myfile = Dir(myPath & myExtension)
  21.  
  22. 'Loop through each Excel file in folder
  23. For i = 1 To 201
  24. Set wb = Workbooks.Open(Filename:=myPath & myfile)
  25. ';;;;;;;;;;;;;;WRITE YOUR CODE HERE
  26. Sheets("SheetName").Select
  27. Columns("A").Select
  28. Selection.Delete
  29. wb.Close SaveChanges:=True
  30.  
  31. Next i
  32. 'Get next file name
  33. myfile = Dir
  34.  
  35. 'Message Box when tasks are completed
  36. MsgBox "Task Complete!"
  37.  
  38. ResetSettings:
  39. 'Reset Macro Optimization Settings
  40. Application.EnableEvents = True
  41. Application.Calculation = xlCalculationAutomatic
  42. Application.ScreenUpdating = True
  43.  
  44. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement