Sub GetFiles()
Dim RowNumber As Long
Range("A1").Value = File
strFolder = ActiveWorkbook.Path
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(strFolder)
RowNumber = RowNumber + 1
Call GetSubFolderSize(strFolder + "\")
End Sub
Sub GetSubFolderSize(strFolder)
a = Cells(Rows.Count, 2).End(xlUp).Row + 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(strFolder)
If folder.subfolders.Count > 0 Then
For Each sf In folder.subfolders
On Error GoTo 100
Call GetSubFolderSize(strFolder + sf.Name + "\")
100 Next sf
End If
'folder size in bytes
On Error GoTo 200
For Each MyFile In folder.Files
Range("B" & a + 1).Value = MyFile.Path
Range("A" & a + 1).Value = MyFile.Size / 1024 ^ 2
' or remove the division for size
Range("C" & a + 1).Value = MyFile.Datelastmodified
a = a + 1
Next MyFile
200 On Error GoTo 0
End Sub