Hello,
I am tring to save some space on my harddrive.
I have a list of directories in excel.
The search results are listed in excel (say column A)
Next (with excel report open), I need to:
1. find out the size of each directory listed in every row of column A
2. print that number (the directory size) in the coresponding rows of Column B
I wrote a small VBA code (based on a VBscript I downloaded, however it does not work.
The error message is:"Object required.."
Please see below the code in the VBA editor in excel
Sub connect()
'Set oFolder = fso.GetFolder(objCurrentFolder)
For i = 1 To 5025
Cells(i, 10).Value = Cells(i, 2).Value + Cells(i, 1).Value
rootfolder = Cells(i, 10).Value
Call CheckFolder(fso.GetFolder(rootfolder), My_Results)
Cells(i, 11).Value = My_Results
Next i
End Sub
Sub CheckFolder(objCurrentFolder, My_Results)
Set oFolder = fso.GetFolder(objCurrentFolder)
For Each objFolder In objCurrentFolder.subFolders
FolderSize = objFolder.Size
Tmp = (FormatNumber(FolderSize, 0, , , 0) / 1024) / 1024
'Wscript.Echo Tmp & " " & objFolder.Path
'raise counter with 1 for a new row in excel
icount = icount + 1
Next
'Recurse through all of the folders
For Each objNewFolder In objCurrentFolder.subFolders
CheckFolder objNewFolder
Next
My_Results = FolderSize
End Sub