+ Reply to Thread
Results 1 to 6 of 6

Code only counts excel files as 1

  1. #1
    Registered User
    Join Date
    10-24-2013
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    3

    Code only counts excel files as 1

    Hello, 2 problems

    My code counts excel files in folders 0-delegation, 3-Preload,6-Postload,8-Defects, 9-DVR as 1 only. Lets say i have 3 excel files in 3-Preload but it pops up as 1 in Excel.

    The goal of this code is to count the number of files in each of those folders posted above. I ran it on our network drive which has over 50GB of data but it keeps freezing Excel. Is there anything I can do? I think that the way it is written, it keeps the data in it's memory. Can someone help me write a lighter code that goes through the filepath and to those folders to count files?

    Thank you!

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Code only counts excel files as 1

    Hello TrajaD,

    Welcome to the Forum!

    If I understand the intent of the macro correctly, you are looking to return the total number of Excel files in each folder and all of it's Subfolders. Is that correct?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    10-24-2013
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Code only counts excel files as 1

    The 'C-XXXX part counts all the folders and excel files in the main folders. The '0-Delegation,etc. part of counts the excel files inside the subfolders. I actually figured it out! But I have a quick question, this macro takes 8 full minutes to go through 40GB of data on a network drive, is it because of my code? or my network is just very slow.

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Code only counts excel files as 1

    Maybe try using filesystemobject?
    Please Login or Register  to view this content.
    that will include non-excel files though, not sure if that its the goal.

  5. #5
    Registered User
    Join Date
    10-24-2013
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Code only counts excel files as 1

    Thanks, I actually found out the solution! I just added an If, Quick fix! Do you guys know why my code runs so long on the network drive (Which is slow). Does my code keep the data in 'memory' instead of just running through it and count?? It takes me over 8 minutes for 40GB of data approximately.

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Code only counts excel files as 1

    I was meaning as a way to speed the code up...

    As far as I'm aware your code will not keep excessive amounts of data in the momery, you kind of answer your own question - the code takes so long because it is running on a slow network drive.

    You could try monitoring the cpu/ram performance as you run the code to make sure I guess.

+ 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. [SOLVED] How do I write a vba code which counts a number of loops?
    By helium in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-25-2012, 07:01 PM
  2. Page counts from links to Word or PDF files
    By darrbeck in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-21-2012, 08:22 AM
  3. VBA code that lookups, stores, and counts unique numbers
    By shadyferret in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-03-2012, 01:15 PM
  4. VBA Code for all excel files
    By Shark Man in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-21-2009, 01:42 AM
  5. Is it possible to have a code that counts coloured cells?
    By Fiona in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-14-2005, 10:06 AM

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