+ Reply to Thread
Results 1 to 16 of 16

Count Rows across Multiple Workbooks

  1. #1
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Count Rows across Multiple Workbooks

    I have found a VBA Macro by searching for this, but it does not seem to work, and was wondering if it was old and needed to be updated or if there is something missing.

    What I am trying to accomplish is I have a directory with 20-30 csv files. Each is a list and I want to run this macro and it list out each sheet and the total number of rows are in each file, without having me to manually open each one and go to the last row and type/write it down and then close the file and repeat.

    Here is the code that I found that isn't working:

    Please Login or Register  to view this content.
    I had the path set correctly just changed to generic.

    Let me know if there is something I need to explain further! Thanks in advance for the help!

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Count Rows across Multiple Workbooks

    I have not looked at your code in details, but this line
    Please Login or Register  to view this content.
    seems to work on the last row in column A. You have not specified which column you are looking for the last row. If it is in the whole sheet1, it is not going to work as you have restrcited you search for column A only.

  3. #3
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Re: Count Rows across Multiple Workbooks

    It is Column A I am looking at.

    Here is the code unmodified and their response on what it should do:
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Re: Count Rows across Multiple Workbooks

    I am just looking to get a count of the number of rows in the sheet that has data in columns A through K, but do not need a count of every cell, just how many rows of data there is.

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Count Rows across Multiple Workbooks

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Re: Count Rows across Multiple Workbooks

    And where does that go within that code?

  7. #7
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Re: Count Rows across Multiple Workbooks

    Also, right now when I run it, it just opens the file, doesn't do anything else, close or nothing.

  8. #8
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Re: Count Rows across Multiple Workbooks

    Anyone else have any ideas?

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Count Rows across Multiple Workbooks

    Please Login or Register  to view this content.
    gives me n, count of 99. You can do similar with your code.

  10. #10
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Re: Count Rows across Multiple Workbooks

    I put that into a Workbook and it doesn't print out anything.

  11. #11
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Re: Count Rows across Multiple Workbooks

    My original code that I posted, seems to work with a really small file, but my actual files that have over 100,000 rows in them it seems to not continue after opening the first file.

  12. #12
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Count Rows across Multiple Workbooks

    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Re: Count Rows across Multiple Workbooks

    Putting that in gives me a Run-time error '13': Type mismatch

  14. #14
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Re: Count Rows across Multiple Workbooks

    If I put this:

    Please Login or Register  to view this content.
    I get:

    Run-time error '6': Overflow

    and since I have a couple small files in the folder it counted them correctly, but stops on the big file.

  15. #15
    Forum Contributor
    Join Date
    11-28-2011
    Location
    St. Louis, Missouri
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    129

    Re: Count Rows across Multiple Workbooks

    Got it to work. Had to change the Integer to Long, and I got what you had started AB33, into the code and it works great.

    Here is the final code that works:

    Please Login or Register  to view this content.

  16. #16
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Count Rows across Multiple Workbooks

    ncurran,
    It was the way you had asked question. If you had wanted the last row, not rows count, I would have spotted the error. I thought you wanted to count how many rows with data you have in each sheet, not the last row with data in each sheet.
    Range("A300000). Yes, an integer could only hold not more than 38000.
    The bottom line is you have now the solution. Great!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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