Sod's law. Most people want sub-folders as well <vbg
Try this
Dim FSO As Object
Dim cnt As Long
Dim arfiles
Sub Folders()
Dim i As Long
Dim sFolder As String
Dim Folder As Object
Dim fldr As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
arfiles = Array()
cnt = 0
sFolder = "C:\myTest"
ReDim arfiles(1)
If sFolder < "" Then
Set Folder = FSO.GetFolder(sFolder)
For Each fldr In Folder.Subfolders
ReDim Preserve arfiles(cnt)
arfiles(cnt) = fldr.Path
cnt = cnt + 1
Next
Worksheets.Add.Name = "Folders"
With ActiveSheet
For i = LBound(arfiles) To UBound(arfiles)
.Cells(i + 1, 1) = arfiles(i)
Next
.Columns("A:Z").EntireColumn.AutoFit
End With
End If
End Sub
--
HTH
RP
(remove nothere from the email address if mailing direct)
"aking1987" wrote in message
...
Works great, except it comes back with subfolders...
3 Folders named EG1, EG2, and EG3, site in location...
X:/EXAMPLE/EXAMPLE/
there are furthur subfolders within eg1, eg2, and eg3.
how can i adjust this so the ONLY list that is displayed on the
worksheet is the original folder names... EG1, EG2, EG3
(obviously EG1,2,3 will change)
Is it possible to mask the location too?
As in all that shows in the sheet (folders) will be EG1,EG2, and
EG3...
no p:/EXAMPLE/EXAMPLE/
MANY THANKS AGAIN!
Antonio
--
aking1987
------------------------------------------------------------------------
aking1987's Profile:
http://www.excelforum.com/member.php...o&userid=15393
View this thread: http://www.excelforum.com/showthread...hreadid=313753