Hello munkee,
This macro will all the folders in a given directory. The list is output to the "Sheet1" starting in cell "A2". The folder name, path, and size are printed in the same row. You can change the directory, worksheet, and starting cell. They are all marked in red.
Sub ListFoldersAndInfo()
Dim FSO As Object
Dim Folder As Object
Dim FolderName As String
Dim R As Long
Dim Rng As Range
Dim SubFolder As Object
Dim Wks As Worksheet
'Parent Directory - Change this to whichever directory you want to use
FolderName = "C:\Documents and settings\Owner\My Documents"
Set Wks = Worksheets("Sheet1")
Set Rng = Wks.Range("A2")
Wks.UsedRange.Offset(1, 0).ClearContents
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder(FolderName)
R = 1
Rng.Cells(R, 1) = Folder.Name
Rng.Cells(R, 2) = Folder.Path
Rng.Cells(R, 3) = Folder.Size
For Each Folder In Folder.SubFolders
R = R + 1
Rng.Cells(R, 1) = Folder.Name
Rng.Cells(R, 2) = Folder.Path
Rng.Cells(R, 3) = Folder.Size
Next Folder
Set FSO = Nothing
End Sub
Bookmarks