Get Collection of Files in Folder

sdday81

New Member
Joined
Feb 28, 2014
Messages
25
Hello, I'm working on a project that requires me working with files and directories. I haven't had any issues yet with setting up user forms, letting users set file paths to folders or even selecting and importing files, etc... but I'm not sure how to grab all the files in a particular folder. I'm a little new to VBA, but not programming.

I used to do stuff like this all the time in C# and C++. In C# you could grab all the files from a folder and then have a collection to loop through rename or do whatever you wanted with them. I'm looking for something similar in VBA.

I'm assuming I would use a FileDialog object, but that's about all I know right now.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Thanks. I will give the Dir Function a try first and see if it will work, if not I'll try the File System Object. How would I add the reference into excel for the FileSystemObject? Would I add it in here or is there a way to include/reference the library in code?



-- removed inline image ---
 
Upvote 0
My Image didn't link before, but this is what I was trying to link:

Reference_zps7de005fb.jpg
 
Upvote 0
Yup, just check that box. That would be the equivalent of importing a library in a C++ project and #include'ing the appropriate header files.
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top