PDA

View Full Version : Combine Multiple Csv Files Into one Worksheets with file name as header



ucan
04-03-2022, 03:51 AM
Hello,
I am looking for a VBA code to combine Multiple Csv Files in a folder into one "Result" Worksheet.
There are two columns in each csv file with multiple .
In result sheet transpose the data as in the image so that each file name appears in rows with their data.
result sheet data starts from A2

29566

p45cal
04-03-2022, 04:31 AM
Go on, I dare you, attach the 3 csv files (not pictures) here and save us some work…

Paul_Hossler
04-03-2022, 10:35 AM
There are two columns in each csv file with multiple .


1. Multiple whats??

2. By 'Header' I'm guessing that you mean a Row Header, like in col D?

3. '111' in is file 1, file 2, and file 3 twice. That are the rules for handling such things?

ucan
04-03-2022, 11:46 AM
I have hundreds of csv file in a folder. Data appears in file as shown in filename1.csv, filename2.csv, filename3.csv,....filename3000.csv.
there are only two columns in each CSV files. first column is same in all files (like January, February, Sunday, Monday etc.), but in column two there are sell prices of each day which is different in different csv files.
As first column in csv files are same, so I can get that as row header in my result sheet and get the different data from csv files below.
Hope this helps.

Aussiebear
04-03-2022, 03:01 PM
As requested in Post#2. Please attach three sample csv files, so it makes it easier for others to assist you. The sample file should be an exact layout of how your actual files look like, but not have any factual data contained within. Images look great but lack the real punch required when asking others for assistance.

Paul_Hossler
04-03-2022, 04:49 PM
Hope this helps.

'Fraid not

We still need realistic sample (#2) files and some answers (#3)

Your screen shots do not have the Col A the same
first column is same in all files (like January, February, Sunday, Monday etc.), and your Col B I don't see
there are sell prices of each day which is different in different csv files.

ucan
04-03-2022, 11:00 PM
My apologies......Here are the three files and the result excel sheet.

Aussiebear
04-04-2022, 01:09 AM
A couple of quick questions;

Is the date important? If, yes then each day needs to separated somehow

Does the number of Credits and/or Sellers need to be unlimited? At the moment your data shows Credit as 1 to 17, Sells as 1 to 36. I can see this becoming an unwieldy spreadsheet over time.

Does this really need to be constructed in Excel? It seems to me that this is simply a dataset with little or no calculations being carried out. Have you thought about dumping this data into a database program instead?

Your Spreadsheet shows the Date in Cell B1, but to my mind that should be the first results of Creditx1. A typo perhaps?

snb
04-04-2022, 01:29 AM
@ucan

Is your alias correct ?
Shouldn't it be Icant ?
Did you ever use the macrorecorder or write any VBA-code ?
Why don't you hire a pro ? (becaude of avarice ?)

Aussiebear
04-04-2022, 05:18 AM
There's an increasing confusion about the integrity of the OP's thread. Might I also suggest there some confusion about the OP themselves. Ucan PM me if you think you have a explanation about the issues here. Until then this issue is closed.