Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I want to copy the names of sub folders from a specific folder to a new
sheet in an existing workbook. I have subfoders under the named subfolders I want copied, but don't want those, just one branch of a tree directory so to speak. TIA Greg |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Greg,
Try this Sub FolderListing() Dim i As Long Dim oFSO As Object Dim oFolder As Object Dim oFldr As Object Dim sOld As String Set oFSO = CreateObject("Scripting.FileSystemObject") i = 2 On Error Resume Next Worksheets.Add.Name = "Folders" On Error GoTo 0 ActiveSheet.Cells.ClearContents Range("A1").Value = "Folder Name" Set oFolder = oFSO.GetFolder("C:\MyTest") For Each oFldr In oFolder.subFolders Cells(i, "A").Value = oFldr.Path i = i + 1 Next oFldr Columns(1).AutoFit End Sub -- HTH Bob Phillips "GregR" wrote in message oups.com... I want to copy the names of sub folders from a specific folder to a new sheet in an existing workbook. I have subfoders under the named subfolders I want copied, but don't want those, just one branch of a tree directory so to speak. TIA Greg |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob, I'll give it a shot as soon as I get to work. I will let you know.
Thanks Greg |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob, worked as expected. Thank you very much
Greg |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Greg, glad it helped.
Regards Bob "GregR" wrote in message oups.com... Bob, worked as expected. Thank you very much Greg |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob, is there any way to amend the code to return only the folder name
rather than the whole path and folder? Greg |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Greg,
Sure there is. Change the line Cells(i, "A").Value = oFldr.Path to Cells(i, "A").Value = oFldr.Name -- HTH Bob Phillips "GregR" wrote in message ups.com... Bob, is there any way to amend the code to return only the folder name rather than the whole path and folder? Greg |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Pulling pdf files from general folder to specific folder | Excel Discussion (Misc queries) | |||
How to decide folder-depth or How to select more folders/subfolders (folder-tree) ? | Excel Discussion (Misc queries) | |||
Need code to save file to new folder, erase from old folder | Excel Discussion (Misc queries) | |||
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? | Excel Discussion (Misc queries) | |||
Finding duplicated entries in a llist | Excel Programming |