Thread: Directory Code
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett[_4_] Don Guillett[_4_] is offline
external usenet poster
 
Posts: 2,337
Default Directory Code

use this that I got here. Chg to suit

Sub FindandListFiles()
Application.ScreenUpdating = False
Columns(1).ClearContents
'ThisRow = 2
'Cells(ThisRow, 1).Select
Dim FN As String ' For File Name
Dim ThisRow As Long
Dim FileLocation As String
FileLocation = "c:\yourfolder\*.xls"
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

"Bill Vernon" wrote in message
...
Is there a way to create a list on a worksheet of all the
file names in the current directory or all files names
with a specific extension such as .txt.

Thank you