Hey guys,
So i'm trying to import a list of folder names but only 1st level and not any subfolders - make sense?
So I got some wicked code from the net that imports folder names and subfolders however I only want to import the lst level of folder names:
Sub ListThem()
Dim startRange As Range
Sheet1.Cells.Clear
Set startRange = Sheet1.Range("A1")
'Parent Directory - Change this to whichever directory you want to use
ListFoldersAndInfo "C:\Documents and Settings\Administrator\My Documents", startRange
End Sub
Sub ListFoldersAndInfo(foldername As String, Destination As Range)
Dim FSO As Object
Dim Folder As Object
Dim R As Long
Dim SubFolder As Object
Dim Wks As Worksheet
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder(foldername)
Destination = Folder.Name
Destination.Offset(0, 1) = Folder.Path
Destination.Offset(0, 2) = Folder.Size
Set Destination = Destination.Offset(1, 0)
For Each SubFolder In Folder.SubFolders
ListFoldersAndInfo Folder.Path & "\" & SubFolder.Name, Destination
Next SubFolder
Set FSO = Nothing
End Su
P.S if the code was taken from:
http://www.excelforum.com/excel-prog...-in-excel.html
Thanks
Wido
Bookmarks