View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
mangesh_yadav[_196_] mangesh_yadav[_196_] is offline
external usenet poster
 
Posts: 1
Default How to Get Folder Names


This will give you only the directory

Sub IndexFiles()

With Application.FileSearch
.LookIn = "C:\MyMusic"
.FileType = msoFileTypeAllFiles
.SearchSubFolders = True
.Execute
End With
cnt = Application.FileSearch.FoundFiles.Count
m = 1
For i = 1 To cnt

Rng = "A" & m


myFile = Application.FileSearch.FoundFiles.Item(i)
x = Split(myFile, "\")
Debug.Print UBound(x)
xLen = Len(x(0))
myDir = x(UBound(x) - 1)
If myDir < k Then
Range(Rng).Value = myDir
m = m + 1
End If
k = myDir

Next i

End Su

--
mangesh_yada

-----------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...fo&userid=1047
View this thread: http://www.excelforum.com/showthread.php?threadid=31863