+ Reply to Thread
Results 1 to 3 of 3

VBA - folder/file names to spreadsheet list

Hybrid View

Apelcius VBA - folder/file names to... 12-11-2012, 06:20 PM
patel45 Re: VBA - folder/file names... 12-12-2012, 02:56 AM
Apelcius Re: VBA - folder/file names... 12-12-2012, 12:03 PM
  1. #1
    Registered User
    Join Date
    10-07-2011
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2010
    Posts
    56

    VBA - folder/file names to spreadsheet list

    Here are the details:

    Archive folder, where I'll prompt it to ask which folder to start from (year). I'd like it to move to the next column, then list the subfolders (months), then for each subfolder list in the next column (for days). Then, lastly, the subfolders (job #), listed in the next column. I've attached an example of what i'd like it to look like after code is done. Is this possible?

    Thanks for any help you guys/gals can give me!!
    Attached Files Attached Files
    --Apelcius--
    Learn. Share. Rinse, Repeat.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: VBA - folder/file names to spreadsheet list

    Sub StartListing()
        
        Dim TopFolderName As String
        Dim TopFolderObj
        Dim DestinationRange As Range
        Set FSO = CreateObject("Scripting.FileSystemObject")
        TopFolderName = "D:\DATA" '<<< CHANGE TO YOUR FOLDER
        Set DestinationRange = Worksheets(1).Range("A1")
        Set TopFolderObj = FSO.GetFolder(TopFolderName)
        ListSubFolders OfFolder:=TopFolderObj, DestinationRange:=DestinationRange
        End Sub
    
       Sub ListSubFolders(OfFolder As Variant, DestinationRange As Range)
        Dim SubFolder
        DestinationRange.Value = OfFolder.Path
        Set DestinationRange = DestinationRange.Offset(1, 1)
        For Each SubFolder In OfFolder.SubFolders
            ListSubFolders OfFolder:=SubFolder, _
                DestinationRange:=DestinationRange
        Next SubFolder
        Set DestinationRange = DestinationRange(1, 0)
        
        End Sub
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    10-07-2011
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2010
    Posts
    56

    Re: VBA - folder/file names to spreadsheet list

    Nice!! Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1