This is not my code. I cannot remeber who authored it - PSC maybe.
Private Sub Path()
On Error GoTo handle
Dim fso, fs, f, x
Set fso = CreateObject("scripting.filesystemobject") 'create
filesystemobject
Set fs = fso.getfolder("c:\") 'gets a hanlde on th
path
' cange as appropriate
Set f = fs.subfolders 'gets a list of al
the folders in the path
Set x = fs.files 'gets a list of al
the files in the path
For Each w In f 'for..next loop
'w this point is the folders in the directory
'for every folder in the list, add it to the subfolder
listbox
' your code here
Next 'loop
For Each v In x
'v lists the files in each folder
' your code here
Next
Exit Sub
handle:
msg = MsgBox("An error has been found. Make sure that the driv
and path exist.", vbCritical, "Error")
End Su
--
Message posted from
http://www.ExcelForum.com