Hi Tobi, Try the below code. Add a reference to 'Microsoft scripting runtime' before using the code.
Sub CreateFolderStructure() Dim fsoobj As FileSystemObject Dim rootpath As String Dim rootfold As Folder Dim fold As Folder Dim subfold As Folder Dim num As Integer Dim subfoldtext As String num = 1 rootpath = "C:\TempFold" Set fsoobj = New FileSystemObject Set rootfold = fsoobj.GetFolder(rootpath) For Each fold In rootfold.SubFolders ActiveSheet.Range("A" + Trim(Str(num))) = fold.Name subfoldtext = "" For Each subfold In fold.SubFolders subfoldtext = subfoldtext & subfold.Name & "," Next ActiveSheet.Range("B" + Trim(Str(num))) = subfoldtext num = num + 1 Next End Sub On Feb 10, 6:15 am, Tobi Hammet <speich...@gmail.com> wrote: > I have the following folder structure: > > /Folder01/Subfolder01 > /Folder01/Subfolder02 > /Folder02/Subfolder01 > /Folder02/Subfolder02 > > list_folders.xls should be in the ROOT > > I want the makro to read the foldernames in Column A, and as a result > i would like to see the Subfolder Names in Column B (Seperated by > comma) > Btw. Subfolders deeper than that can be ignored - so its basically > about the subfolders in the folders that are listed in Column A. > Also Files can be ignored! > > So with the above folder structure, having filled in A1&A2 before, it > should look like this: > > A1="Folder01" >> B1="Subfolder01,Subfolder02" > A2="Folder02" >> B2="Subfolder02,Subfolder02" > > Can anyone solve this? > It seems quite tricky... > > PS: i also uploaded a .xls file that should show more visually what i > want.http://sites.google.com/site/excelauswahl/excel-vba > (the zip already contains the folder structure so its easy to > test....) > > PS: The current macro doesnt really work, thats why i am posting > here ;) --~--~---------~--~----~------------~-------~--~----~ Visit the blog to download Excel tutorials at http://www.excel-macros.blogspot.com To post to this group, send email to excel-macros@googlegroups.com For more options, visit this group at http://groups.google.com/group/excel-macros?hl=en Visit & Join Our Orkut Community at http://www.orkut.com/Community.aspx?cmm=22913620 To Learn VBA Macros Please visit http://www.vbamacros.blogspot.com To see the Daily Excel Tips, Go to: http://exceldailytip.blogspot.com If you find any spam message in the group, please send an email to Ayush @ jainayus...@gmail.com -~----------~----~----~----~------~----~------~--~---