Thread: Folder listing
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Héctor Miguel Héctor Miguel is offline
external usenet poster
 
Posts: 434
Default Folder listing

hi, Esra !

I want to get a folder listing (from a specific folder) that shows sub folders in the next column (under the parent folder)...


does a vba-macro serves well ?

Sub List_Subfolders()
Dim StartPath As String, FName As String, n As Integer
StartPath = Range("a1").Text
If Right(StartPath, 1) < "\" Then StartPath = StartPath & "\"
FName = Dir(StartPath & "*", vbDirectory)
Do While FName < ""
If (GetAttr(StartPath & FName) And vbDirectory) = vbDirectory Then _
If FName < "." And FName < ".." Then _
Range("b1").Offset(n) = FName: n = n + 1
FName = Dir()
Loop
End Sub

hth,
hector.