LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default lIST dIRECTORY

If in Excel 2000 or later:

Sub ListfilesInDirectory()
Dim direc
Dim fs As Variant
Dim LooKin As Validation
Dim FileName As Variant
Dim i As Integer

'direc = Range("ad2")
direc = "C:\Data"
Sheets("Test").Select
Range("a1").Select
Set fs = Application.FileSearch
With fs
.Lookin = direc
.FileName = ".xls"
If .Execute 0 Then
For i = 1 To .FoundFiles.Count
varr = Slit(.Foundfiles(i),"\")
ActiveCell.FormulaR1C1 = varr(ubound(varr))
ActiveCell.Offset(1, 0).Select
Next i
Else
End If
End With
End Sub

--
Regards,
Tom Ogilvy



"Geno" wrote in message
...

Thanx a lot, now how do I eliminate the directory name and simply
display the filenames?


--
Geno
------------------------------------------------------------------------
Geno's Profile:

http://www.excelforum.com/member.php...o&userid=16380
View this thread: http://www.excelforum.com/showthread...hreadid=214248



 
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 can I change list into a directory format? Becky Ed Excel Worksheet Functions 1 August 3rd 06 05:25 PM
List of Files in A Directory JaneC Excel Discussion (Misc queries) 2 February 18th 06 12:11 PM
list directory in EXCEL Bob Phillips Excel Discussion (Misc queries) 1 January 17th 06 04:23 PM
List of folders in a certain directory woolyhedgehog Excel Discussion (Misc queries) 1 October 19th 05 04:28 PM
list box- list all files ina directory suee Excel Programming 9 April 7th 04 02:32 AM


All times are GMT +1. The time now is 11:45 PM.

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

About Us

"It's about Microsoft Excel"