![]() |
Filenames into Excel
Using VBA, can anyone tell me know to get all the filenames in a given folder into an Excel spreadsheet. I would like to have each filename in a separate cell. For example, Filename1.txt in A1, Filename2.txt in A2, Filename3.txt in A3, etc. The number of data files (*.txt) will vary each day
Thanks in advance Lee |
Filenames into Excel
modify this to suit
Sub FindandListFiles() Application.ScreenUpdating = False Columns(1).ClearContents ThisRow = 2 Dim FN As String ' For File Name Dim ThisRow As Long Dim FileLocation As String FileLocation = "c:\yourfolder\*.txt" FN = Dir(FileLocation) Do Until FN = "" ThisRow = ThisRow + 1 Cells(ThisRow, 1) = FN FN = Dir Loop Application.ScreenUpdating = True End Sub -- Don Guillett SalesAid Software "Lee" wrote in message ... Using VBA, can anyone tell me know to get all the filenames in a given folder into an Excel spreadsheet. I would like to have each filename in a separate cell. For example, Filename1.txt in A1, Filename2.txt in A2, Filename3.txt in A3, etc. The number of data files (*.txt) will vary each day. Thanks in advance, Lee |
All times are GMT +1. The time now is 05:45 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com