Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display a list of FOLDERS in Column A 1

Status
Not open for further replies.

addicted2

MIS
Jan 16, 2002
16
AU
Hi,can anyone show me a code that will lookin C:Household and display a list of it's sub folders in Column A of the active worksheet.

Thanks all B-)
Cheers
Tony
 
Using the FileSystem Object the following will do what you want :
Code:
Sub ListFolders()
Dim fso, fldr, i As Long
    i = 0
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set fldr = fso.GetFolder("C:\Household")
    For Each Folder In fldr.SubFolders
        Range("A1").Offset(i, 0).Value = Folder.Name
        i = i + 1
    Next
    Set fso = Nothing
    Set fldr = Nothing
End Sub

AC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top