Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Lee Lee is offline
external usenet poster
 
Posts: 7
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to save mp3 filenames in a cd to excel format Suresh Gopi Excel Discussion (Misc queries) 1 October 16th 09 02:07 PM
Copy Filenames AND details to Excel deeds Excel Discussion (Misc queries) 1 December 7th 07 09:25 PM
using excel to rename filenames? vmorgan Excel Discussion (Misc queries) 1 March 14th 06 06:12 PM
How to create Automatic Filenames in Excel Trevor6410 Excel Discussion (Misc queries) 1 November 23rd 05 05:05 PM
Brackets in Excel filenames JT Lovell Excel Programming 1 November 21st 03 01:59 AM


All times are GMT +1. The time now is 12:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"