VBA Copy multi CSV/Excel files from Folder to one WorkBook

MC01_

New Member
Joined
Dec 1, 2020
Messages
3
Office Version
  1. 2019
Platform
  1. Windows
Greetings, i hope you all are good.
After read lots a post in this Forum, I have find a VBA in this forum to copy files in .xmlx and other to do the same on .csv files to one single sheet.

Can it be possible the same VBA run it this two types of files? And copy them to a master WorkBook organize by the name of the folders?

In the case of . CSV files after the copy to the Master Workbook can it transform only the colluns in number to text.

I have a folder whit sub-folders and in that subfolders the files to merge (sometimes 1 unic file but at the end of each moth they are 20 files)


The post i read and use is this : https://www.mrexcel.com/board/threads/copy-specific-files-from-folder-and-sub-folder.1147092/

Can anybody help me please.
 

Attachments

  • Folder.PNG
    Folder.PNG
    3.6 KB · Views: 13
  • Files.PNG
    Files.PNG
    1.9 KB · Views: 13
  • Test final.PNG
    Test final.PNG
    4.9 KB · Views: 13

Some videos you may like

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

MC01_

New Member
Joined
Dec 1, 2020
Messages
3
Office Version
  1. 2019
Platform
  1. Windows
Who can I use this for my needs
From this VBA i just merge only one file at time

Sub test()
Dim Wb1 As Workbook, Wb2 As WorkBook, Wb3 As Workbook
Dim MainBook As Workbook

'Open All workbooks first:
Set Wb1 = Workbooks.Open(" book1.xlsx")
Set Wb2 = Workbooks.Open(" book2.xlsx")
Set Wb3 = Workbooks.Open(" book3.xlsx")
Set MainBook = Workbooks.Open(" Masterbook.xlsx")

'Now, copy what you want from wb1:
wb1.Sheets("Sheet1").Cells.Copy
'Now, paste to Main worksheet:
MainBook.Sheets("Sheet1").Range("A1").PasteSpecial

'Now, copy what you want from wb2:
wb2.Sheets("Sheet1").Cells.Copy
'Now, paste to Main worksheet:
MainBook.Sheets("Sheet2").Range("A1").PasteSpecial

'Now, copy what you want from wb3:
wb3.Sheets("Sheet1").Cells.Copy
'Now, paste to Main worksheet:
MainBook.Sheets("Sheet3").Range("A1").PasteSpecial

'Close Wb's:
Wb1.Close
Wb2.Close
Wb3.Close
MainBook.Save
MainBook.Close

End Sub

Please Help
 

Watch MrExcel Video

Forum statistics

Threads
1,128,128
Messages
5,628,864
Members
416,346
Latest member
Sekolaine

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top