ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Listing files in directories. (https://www.excelbanter.com/excel-programming/271368-listing-files-directories.html)

skmr3

Listing files in directories.
 
Hi All.
I have this below coding to list all files in a directory.
However i need to modify the code to modify the code to
display the folder path along with the file name.
If possible as well, i need to modify the coding to also
list files located in sub-directories as well.
Any help would be greatly appreciated.
Cheers.
Skmr3.

Sub DisplayFilesInDirectory()
Dim fs, f, f1, fc, s
Dim Folder
Folder = "???"
Set fs = CreateObject("scripting.filesystemobject")
Set f = fs.GetFolder(Folder)
Set fc = f.Files
For Each f1 In fc
ActiveCell.Value = s & f1.Name
ActiveCell.Offset(1, 0).Activate
Next

End Sub


All times are GMT +1. The time now is 07:06 AM.

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