15-May-2009 NEW UTILITY: List Files In Folder

This utility will list all the files in a folder and subfolders.
- It's like a big browser
- You choose:
- The folder to start at
- Whether to include subfolders
- A limit on the number of files you want to return
- Set this to a small number to test if it's working
- Then set it to a big number for your run
- Choose the format you want by formatting the cells on the sheet
- Choose your own sort order for the results
- Then Press "List Files"
- Your files will be listed
- A pivot table will be created
- You can do lots of things with the pivot table
- Create a list of folders and size of the files
- Find how many files are in the folders
- Find duplicate files
- Split out files by file type
- etc...
- You can do lots of things with the pivot table
Here's a screen shot of the main screen in Excel:
Here's the output in Raw form:
Here's one of the things you can do with the data:
- put it in a pivot table and find out the size of the files in each folder
Training Video on how to List Files In Folder in Excel:
| Attachment | Size |
|---|---|
| list-files-in-folder-Excel-2003.xls | 292.5 KB |
| list-files-in-folder-Excel-2007.xls | 313 KB |
| list-files-in-folder-Excel-2007-Row-Limit-Extended.xlsm | 242.52 KB |
»
- Nick's blog
- Add new comment
- 9380 reads

change category list
I absolutely love this file. I would like to add or change the categories that the file selects. Like adding Genre or Artist. could you provide step by step instrucions to create this file from scratch?
Genre
Not sure how to add Genre, I didn't see it in the list available to VBA... will leave that one open to the audience.
List files in folder
I need to change the limit on the Stop_After value. My directory has more than 65000 rows. Can you help with this?
override the data validation
You can override data validation by typing your value in a cell in a new workbook, then copying it and pasting onto the "Stop After This Many Files" cell.
File limit
Can you please assist to allow up to the maximum rows in excel2007 please
File limit extended
I have now added a new file:
list-files-in-folder-Excel-2007-Row-Limit-Extended.xlsm
General
Many thanks for this. Whilst I have done this in cmd, this is far easier for the average excel user to be able to run, view, and make use of.
Using over network causes macro to freeze.
If i run the macro over 50 or so files, it works fine. However, if there are alot of files in a folder, the macro will freeze and i have to use the system to shut down VBA and Excel. Any ideas?
Thanks,
Wayne Hilburn
whilburn at yahoo.com
network problem
sounds to me like you either have a folder with a huge amount of files, or a network problem.
one more thing it could be... if you deselect Excel when running code, sometimes it looks like it has frozen, but it hasn't..
Try running it on a single folder on the network
network problem
I originally ran the macro at home on a local network. The number of files were around 4000. I waited approx. 30 min and excel was in a frozen status.
I reran the macro at work on a network folder that contained the same approx number of files. It ran successful in approx 12 min.
I stopped screen updating and it helped some. Overall it works fine, but i was wondering if there was something else to consider to make the macro run more efficiently.
thanks,
Wayne
Add Owner to Excel 2003 version
Is there anyway I can add Owner of each file to the output.
Thanks
Steve Heron
owner
Where do you see this info ?
owner
I see it in Windows Explorer and can be seen through DOS Dir command so I have assumed it is available. Am I wrong in that assumption.
Owner
I have now soted this.
Thanks
Steve
HyperLink to files
Any way to add VB code to add a Hyperlink, to each file, so it can be opened from within Excel? I have 30,000 files in one Directory and it would be helpful if I could open them right from Excel...
Thanks!!
Changing the Code to Retrieve Only What You Need
I have to collect file information data for my boss. It's well over 65,000 files. I am using excel 2003 and have two questions: how do dump data into multiple sheets and/or how do you get the code to only retrieve what you want? For example, I need to find information on all the files that date back before January 2010 so I can remove them.
Request a quote
Happy to provide a customised solution:
Request a quote
hyperlinks?
Hey Nick,
Is there a way to automatic generate hyperlinks to the listed files?
btw cool setup.
gr MRW
hyperlinks to files
If they're Excel files, you should be fine... use hyperlinks.add
For other files, more complicated
Okay, I just gonna try
Okay, I just gonna try somethings,
I let you know if it works.
thnx MRW
hyperlinks?
Hey Nick,
I create a macro that generate Hyperlinks, and now i want to put those in a new sheet,
but the file is protected so I can modify/add the sheets,
Is there a way that i can get a not protected file?
thnx Mrw
post code
post the code here, and I will incorporate..
Additional Folders!
Hey Nick,
Great website you have, has been really helpful so far! I am trying to adapt your listing program here to accomodate additonal folder locations instead of copying the macro itself 20 different times. I have basic knowledge of coding, but nothing too intricate, though I am a quick learner. Im assuming you would have to edit the sub: ListMyFiles(mySourcePath, IncludeSubfolders) to have it run through additonal folders once you have the correct fields set up and information entered on the first worksheet. Any thoughts?
Thanks,
Matt
try this: sub
try this:
sub RunMultipleFolders()
call ListMyFiles("c:\myFolder", false)
call ListMyFiles("c:\myFolder1", false)
end sub
Step Through
Thanks Nick for the quick reply! I can continue calling the sub by editing the VBA but what if i had the layout set up in columns and wanted the VBA to continue down alist of folder locations/include_subfolders/file limit until there were no more folders listed?
put the list of folders in a