Import file names into cells

C

craigwojo

Hi everyone,

I need to take file names from directories on my hard dirve and impor
the file name into a cell. I don't want to type all the file name
into each cell. Also if I add a file to the directory I would like i
to update the excel sheet and put the file in the correct place. I
the second part is hard to understand, forget about it, I really nee
the first part of this question.

Thank you,
Crai
 
D

Don Guillett

This macro will make a list of all files in "yourfolder". Change to suit. If
you only want excel files, uncomment the .filename line.

With Application.FileSearch
.NewSearch
.LookIn = "c:\YourFolder"
'.SearchSubFolders = True 'False
'.FileName = ".xls" 'Your file types
If .Execute > 0 Then
For iCtr = 1 To .FoundFiles.Count
Cells(iCtr, 1).Value = .FoundFiles(iCtr)
Next iCtr
End If
End With
 
G

Gord Dibben

Craig

Several methods to accomplish this.......I like Tushar's best.

To add a "Print Directory" feature to Explorer, go to
this KB Article.

http://support.microsoft.com/default.aspx?scid=KB;EN-US;q272623&

Or you can download Printfolder 1.2 from.....

http://no-nonsense-software.com/freeware/

I use PF 1.2 and find it to be more than adequate with custom features.

OR Go to DOS(Command) prompt and directory.
Type DIR >MYFILES.TXT

All the above create a *.TXT file which can be opened in Excel.

One more method if you want to by-pass the *.TXT file and pull directly to
Excel is to use Tushar Mehta's Excel Add-in. This allows filtering and
sorting once you have the data in Excel.

http://www.tushar-mehta.com/ scroll down to Add-ins>Directory Listing.

Download the ZIP file and un-zip to your Office\Library folder.

As to the second part of mission........the updating part......I think you
would just have to re-import all filenames again from the folder.

Gord Dibben Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top