List Subfolders Horizontally, seperated by comma, instead ofvertically

T

Tobi Harnegg

I finally managed to do this script almost what i want:
it is listing the subfolders of a folder-name that i put in A1

But instead of having the result in Collumn B BELOW each other, i
would like to have it
next to each other, into 1 cell (in this case, B1), seperated by
comma.

Example: A1="Folder" B1="Subfolder1,Subfolder2,Subfolder3"

Sub tt()
Dim FSO, FO, FU, F
Set FSO = CreateObject("Scripting.FileSystemObject")
Set FO = FSO.GetFolder(ActiveWorkbook.Path & "/" & Range("A1"))
Set FU = FO.SubFolders
For Each F In FU
Range("B65536").End(xlUp).Offset(1, 0).Value = Right(F, Len(F) -
InStrRev(F, "\"))
Next F
End Sub

PS: i dont need to go to a deeper level of subfolders (dont need to
see what folders are in, e.g. subfolder1)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top