ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   List Filenames from Folder (https://www.excelbanter.com/excel-programming/361953-list-filenames-folder.html)

Eskimo

List Filenames from Folder
 
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

Chip Pearson

List Filenames from Folder
 
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


"Eskimo" wrote in message
...
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





All times are GMT +1. The time now is 01:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com