Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Subdirectories
Hello all,
I've seen various Macros that will list files in a Directory. I'm looking for a Macro that will list subdirectories in a directory. I would like the Macro result printed to a blank sheet in a single column just containing the sub-directory name. It only needs to go down 1 level - don't need sub-directories in sub-directories. The plan is to use this data to populate a listbox - unless the listbox could be populated directly. Is this possible? Many thanks. Paul. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Subdirectories
Hi Paul,
Skip wrote: I've seen various Macros that will list files in a Directory. I'm looking for a Macro that will list subdirectories in a directory. I would like the Macro result printed to a blank sheet in a single column just containing the sub-directory name. It only needs to go down 1 level - don't need sub-directories in sub-directories. The plan is to use this data to populate a listbox - unless the listbox could be populated directly. You can use the FileSystemObject to do this pretty easily. The following code assumes you have a ListBox on Sheet1 named "lstSubFolders": Sub PopulateSubFolders() Dim fso As Object Dim fol As Object Sheet1.lstSubFolders.Clear Set fso = CreateObject("Scripting.FileSystemObject") For Each fol In fso.GetFolder("C:\Program Files").SubFolders Sheet1.lstSubFolders.AddItem fol.Name Next fol Set fso = Nothing End Sub -- Regards, Jake Marx MS MVP - Excel www.longhead.com [please keep replies in the newsgroup - email address unmonitored] |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Subdirectories
Refer to Steve Yandl's post on 08/25/2004 You will find some help ther
MD "Skip" a écrit dans le message de ... Hello all, I've seen various Macros that will list files in a Directory. I'm looking for a Macro that will list subdirectories in a directory. I would like the Macro result printed to a blank sheet in a single column just containing the sub-directory name. It only needs to go down 1 level - don't need sub-directories in sub-directories. The plan is to use this data to populate a listbox - unless the listbox could be populated directly. Is this possible? Many thanks. Paul. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Subdirectories
also see the help example for the Dir command
-- Regards, Tom Ogilvy "Skip" wrote in message ... Hello all, I've seen various Macros that will list files in a Directory. I'm looking for a Macro that will list subdirectories in a directory. I would like the Macro result printed to a blank sheet in a single column just containing the sub-directory name. It only needs to go down 1 level - don't need sub-directories in sub-directories. The plan is to use this data to populate a listbox - unless the listbox could be populated directly. Is this possible? Many thanks. Paul. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Subdirectories
Thanks all - advice much appreciated
"Tom Ogilvy" wrote in message ... also see the help example for the Dir command -- Regards, Tom Ogilvy "Skip" wrote in message ... Hello all, I've seen various Macros that will list files in a Directory. I'm looking for a Macro that will list subdirectories in a directory. I would like the Macro result printed to a blank sheet in a single column just containing the sub-directory name. It only needs to go down 1 level - don't need sub-directories in sub-directories. The plan is to use this data to populate a listbox - unless the listbox could be populated directly. Is this possible? Many thanks. Paul. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
list of all subdirectories in a given directory in excel | Excel Worksheet Functions |