Macro to open mulitple csv files and complie data into spreadsheet

molsonlabatt

New Member
Joined
Jul 25, 2012
Messages
14
Hi,
I have been running in circles trying to find a way to get this to work.

What I would like to be able to do is have a macro that can import a column of data from multiple CSV files (that each have the same name) into a spreadsheet. Details below:

1. Have a dialog box to prompt the user to enter the main folder (will change everyday) e.g.:
Dim dlgOpen As FileDialog
Set dlgOpen = Application.FileDialog(msoFileDialogFilePicker)
With dlgOpen
.AllowMultiSelect = True
''Start in
.InitialFileName = "C:\UsersDesktop\HPLC\13DEC02

2. Have the macro then look through the multiple sub folders (within main folder) for the file name "REPORT01.CSV" and copy a column of data from that file into a spreadsheet. This file appears in each subfolder.

3. Too keep track of were the data came from, I need the subfolder name (e.g. BLK1.D) to appear above the column of copied data.

Thank you in advance
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,215,436
Messages
6,124,869
Members
449,192
Latest member
MoonDancer

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
Back
Top