Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default 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   Report Post  
Posted to microsoft.public.excel.programming
MD MD is offline
external usenet poster
 
Posts: 26
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
list of all subdirectories in a given directory in excel Peter STEVENS Excel Worksheet Functions 3 February 11th 06 03:32 PM


All times are GMT +1. The time now is 12:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"