+ Reply to Thread
Results 1 to 2 of 2

Count Rows in all files in a directory

  1. #1
    Registered User
    Join Date
    05-09-2016
    Location
    USA
    MS-Off Ver
    2013
    Posts
    1

    Count Rows in all files in a directory

    Hi experts,

    I have a directory with a couple of thousand CSV files, and I need to get the number of records in each file as well as the total number of records in all the files. How can I write a VBA script to accomplish this? I have tried a script that merges all the files but this is very time consuming and often times the merged file cannot hold all the records from the source files.

    Thanks in advance for your help!
    Cheers,

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Count Rows in all files in a directory

    In the past I have used a super simple BAT file to combine the CSV files then pulled them into POWERPIVOT (although access might work as well).
    I believe I had 24M rows of data before they let me have a SQL table to play in so row count shouldnt be an issue.

    Simple .bat file creation:
    http://stackoverflow.com/questions/2...ing-batch-file


    If you wanted to go the VBA route I would absolutely use ADO.
    This might get you started.
    http://www.vbaexpress.com/forum/show...V-or-Text-File
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

+ 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. Moving Files from one directory structure to another directory
    By harddd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-17-2013, 02:39 PM
  2. How can i get the records/rows count of files in a directory
    By anaconte1010 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-01-2013, 12:54 PM
  3. [SOLVED] Macro to Import Multiple TXT Files into workbook - User to select files/directory
    By saber007 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-15-2013, 08:43 PM
  4. How to count # of .xls files in a directory - I NEED HELP PLEASE
    By anaconte1010 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-10-2013, 12:04 PM
  5. Macro to Move files from one directory to other directory
    By Shanthuday in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-05-2013, 07:21 AM
  6. Program to open and append all files in a given directory......not work at ~ 92k rows
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-14-2011, 08:50 PM
  7. Reading in the files in a directory into an array, directory chosen by user
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-18-2011, 12:52 PM
  8. Count files in directory
    By Vlad999 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-21-2006, 07:40 PM

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