+ Reply to Thread
Results 1 to 3 of 3

VBA question: Import 100s of .csv files - each in a separate column?

  1. #1
    Forum Contributor
    Join Date
    08-25-2015
    Location
    London
    MS-Off Ver
    MS 365
    Posts
    213

    VBA question: Import 100s of .csv files - each in a separate column?

    Hi all,

    I have around 500 individual .csv files that each contain one column of data (row 1 to row 1,048,576...so rows are maxed out in each file).
    I need to find a way to combine all.csv files (in one specific folder) into one .csv file on one tab, e.g.

    file 1: import to first column
    file 2: import to second column on same tab
    file 3: import to third column on same tab
    and so on...

    Is this something that could be achieved using VBA? If so, would anyone be able to help?

    Thanks so much!

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,879

    Re: VBA question: Import 100s of .csv files - each in a separate column?

    Look into appending the files to each other in Power Query. You will need to have all the files in the same folder.

    https://docs.microsoft.com/en-us/pow...bine-files-csv
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    08-25-2015
    Location
    London
    MS-Off Ver
    MS 365
    Posts
    213

    Question Re: VBA question: Import 100s of .csv files - each in a separate column?

    Hi Alan,

    Thanks for the tip! Tried that, but somehow ended up merging all files into one row and again exceeding the max row count.

    I found this VBA which seems to do what I want to do, but...

    1)...somehow it isn't working if I change the range from A1:A10 to, let's say A1:A1048576 (maximum number of rows)
    2) I wouldn't want it to copy the file name in the first row for each file
    3) Ideally, I would pick a folder each time I run this rather than having to paste the path

    Do you think there's any way to tweak this?

    Please Login or Register  to view this content.
    Thanks so much for the help!
    Last edited by kingofcamden; 11-20-2020 at 02:30 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA to Delete Specific Columns 100s Files for .csv
    By Tommy1005 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-11-2020, 04:25 PM
  2. VBA to Delete Specific Rows 100s Files for .csv
    By davidp13 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-08-2017, 06:06 PM
  3. Import Macro to import separate files to separate worksheets - deletes existing worksheets
    By Hondahawkrider in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-01-2015, 02:24 PM
  4. Replies: 4
    Last Post: 08-11-2015, 04:47 PM
  5. import multiple XER files into separate Excel Spreadsheets
    By amchale in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-20-2014, 11:41 AM
  6. Replies: 50
    Last Post: 02-12-2010, 01:35 PM
  7. Import 2 text files into 2 separate columns?
    By tcurrier in forum Excel General
    Replies: 3
    Last Post: 02-11-2006, 03:13 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1