List Filenames from Folder

E

Eskimo

Hi,

I wonder if it's possible to populate a column in excel with filenames that
come from a folder. I need only to import only the file names and not any of
the data within the files.

All the files names that I need end with *.txt

Thanks,

Eskimo
 
C

Chip Pearson

Try something like

Dim Rng As Range
Dim FName As String
Set Rng = Range("A1")
FName = Dir("H:\Test\*.txt") '<<< CHANGE PATH
Do Until FName = ""
Rng.Value = FName
Set Rng = Rng(2, 1)
FName = Dir()
Loop

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 

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