Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping through a Directory using VBA

Status
Not open for further replies.

tmckinno43

Technical User
May 3, 2005
2
US
I need to import a series of text files into an Excel spreadsheet. The text files are located in three subdirectories under a specific parent directory path.

I was hoping someone might have some code which they've used before to loop through a directory so that they could provide the directory name and file name of each directory's contents into a two-dimensional array.

I know that I could figure this out on my own. I'm basically hoping that I could save time by leveraging someone else's work. Let me know if this is OK. I'm a newbie to this forum.

Thanks,

Ted
 
Check out this thread to see if it covers what you're looking for.

thread707-694785
 
tmckinno43,
Another route would be to look at [tt]Application.FileSearch[/tt]. It's faster than most [tt]VBA[/tt] or [tt]FileSystemObject[/tt] methods and you can use the [tt]FoundFiles[/tt] collection in lieu of an array to process the, er, eh, found files.

Hope this helps,
CMP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top