LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default macro listing subfolders from selection of mainfolders

Hey Guys
I hope you will help me again :)

I found this macro at Tom Ogilvys (thanks Tom).
It generates a name-list of the subfolders in the one mainfolder c:
\MyRoot\

My challenge is to make a analogous list of all the subfolders (only
the 4 caractres to the left in the subfoldername) in a selection of
mainfolders.
The selection of mainfolder is based on the beginng of foldername: "H:
\Order *\".

H:\order 2004\
H:\order 2005\
H:\order 2006\
H:\order 2007\
and so on

The final list will go like this:
0104
0204
...
1504
0105
0205
0305
....
9905
and so on.



Sub ListSubs()
Dim MyPath As String, MyName As String
Dim rw As Long


rw = 1
MyPath = "c:\MyRoot\" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
Do While MyName < "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If MyName < "." And MyName < ".." Then
' Use bitwise comparison to make sure MyName is a directory.
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
Cells(rw, 1).Value = MyName ' Display entry only if it
rw = rw + 1 ' represents a directory.
End If
End If
MyName = Dir ' Get next entry.
Loop
End Sub

Do anyone feel to guide me on this one?

Best Regards Snoopy


 
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
Macro to Find File in Subfolders and Open it K[_2_] Excel Programming 2 March 10th 09 04:54 PM
run macro on all closed workbooks in folder and subfolders spence Excel Programming 3 May 2nd 07 07:52 PM
SubFolders in macro pianoman[_4_] Excel Programming 2 April 28th 06 03:25 PM
copy subfolders, replace text in files and save files in copied subfolders pieros Excel Programming 0 November 1st 05 12:08 PM
Listing a selection of data from one worksheet on another supersimon2000 Excel Discussion (Misc queries) 1 October 20th 05 02:45 PM


All times are GMT +1. The time now is 10:27 PM.

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

About Us

"It's about Microsoft Excel"