Consulting

Results 1 to 10 of 10

Thread: Combine Multiple Csv Files Into one Worksheets with file name as header

  1. #1
    VBAX Regular
    Joined
    Feb 2022
    Posts
    24
    Location

    Combine Multiple Csv Files Into one Worksheets with file name as header

    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

    multiplesheet input(file names) and output(result sheet).jpg

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,873
    Go on, I dare you, attach the 3 csv files (not pictures) here and save us some work…
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    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?
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  4. #4
    VBAX Regular
    Joined
    Feb 2022
    Posts
    24
    Location
    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.

  5. #5
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,055
    Location
    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.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    Quote Originally Posted by ucan View Post
    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.
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  7. #7
    VBAX Regular
    Joined
    Feb 2022
    Posts
    24
    Location
    My apologies......Here are the three files and the result excel sheet.
    Attached Files Attached Files

  8. #8
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,055
    Location
    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?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  9. #9
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,642
    @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 ?)

  10. #10
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,055
    Location
    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.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •