+ Reply to Thread
Results 1 to 7 of 7

How to get total no. of file in folder?

  1. #1
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    How to get total no. of file in folder?

    The code below can get no. of file in folder F:\PIC,

    folderPath = "F:\PIC"
    Set FSO = CreateObject("Scripting.FileSystemObject")
    noOfFiles = FSO.GetFolder(folderPath).Files.count


    How to modify "F:\PIC" so that it can get total no. of file
    inside any folders that are in F:\PIC?

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,282

    Re: How to get total no. of file in folder?

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    Re: How to get total no. of file in folder?

    bakerman2,

    Can I just modify "F:\PIC" to something like "F:\PIC\*.*" etc so as to include all files in folder "PIC"?

    If not, please revise your VBA so that the folderPath = "F:\PIC".

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,282

    Re: How to get total no. of file in folder?

    It is possible but where or how do you want results to be displayed?
    Do you want count per subdirectory or total of all files in directory F:\PIC and all subdirectories?

  5. #5
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    Re: How to get total no. of file in folder?

    I want all files in directory F:\PIC and all subdirectories.
    (the result shows on say Cell B1 of active excel)
    Last edited by london7871; 07-14-2016 at 10:46 PM. Reason: Clarify location of result

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,282

    Re: How to get total no. of file in folder?

    Please Login or Register  to view this content.
    Last edited by bakerman2; 07-15-2016 at 01:26 AM.

  7. #7
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    Re: How to get total no. of file in folder?

    Thanks bakerman2

    I will revise the above to suit my actual situation.

+ 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. Create folder and move files to that folder based on file name
    By biznez in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-26-2016, 06:58 PM
  2. Replies: 2
    Last Post: 12-29-2015, 04:19 AM
  3. [SOLVED] Lookup folder from cell text, then save excel file in this folder
    By dodgybob in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-14-2014, 09:00 AM
  4. search for a file in a folder based on data, copy and paste it in another folder
    By kboy1289 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2013, 11:47 AM
  5. Create Folder with system date then save file to folder
    By cartotech81 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-06-2009, 02:12 PM
  6. Replies: 6
    Last Post: 08-11-2006, 03:41 PM
  7. [SOLVED] macro to move from file to file, folder to folder
    By davegb in forum Excel General
    Replies: 0
    Last Post: 01-21-2005, 04:06 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