Advertisement
aminsbd

KUTOOL MERGER

Feb 9th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. Sub simpleXlsMerger()
  2. Dim bookList As Workbook
  3. Dim mergeObj As Object, dirObj As Object, filesObj As Object, everyObj As Object
  4. Application.ScreenUpdating = False
  5. Set mergeObj = CreateObject("Scripting.FileSystemObject")
  6.  
  7. 'change folder path of excel files here
  8. Set dirObj = mergeObj.Getfolder("E:\Amin\ITK\Desember 2018\07 Desember 2018")
  9. Set filesObj = dirObj.Files
  10. For Each everyObj In filesObj
  11. Set bookList = Workbooks.Open(everyObj)
  12.  
  13. 'change "A2" with cell reference of start point for every files here
  14. 'for example "B3:IV" to merge all files start from columns B and rows 3
  15. 'If you're files using more than IV column, change it to the latest column
  16. 'Also change "A" column on "A1048576" to the same column as start point
  17. Range("A1:IV" & Range("A1048576").End(xlUp).Row).Copy
  18. ThisWorkbook.Worksheets(1).Activate
  19.  
  20. 'Do not change the following column. It's not the same column as above
  21. Range("A1048576").End(xlUp).Offset(1, 0).PasteSpecial
  22. Application.CutCopyMode = False
  23. bookList.Close
  24. Next
  25. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement